Computer Organization and Architecture (COA) Chapter - 1 Introduction of Computer

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 44

Computer Organization and Architecture (COA)

Chapter -1

Introduction of computer

In today's world, we use computers for all our tasks. Our day-to-
day activities: paying bills, buying groceries, using social media,
seeking entertainment, working from home, communicating with a
friend, etc., can all be done using a computer. So it is important not
only to know how to use a computer, but also to understand the
components of a computer and what they do.

This topic explains all concepts related to computer in detail, from


origin to end. The idea of computer literacy is also discussed, which
includes the definition and functions of a computer. You learn about
the components of a computer, the concept of hardware and
software, representation of data/information, the concept of data
processing and applications of IECT.

What is a Computer?
A computer is an electronic device that accepts data from the user,
processes it, produces results, displays them to the users, and
stores the results for future usage.
Data - is a collection of unorganized facts & figures and does not
provide any further information regarding patterns, context, etc.
Hence data means "unstructured facts and figures".
Information - is a structured data i.e. organized meaningful and
processed data. To process the data and convert into information, a
computer is used.

Functions of Computers

A computer performs the following functions −

Receiving Input

Data is fed into computer through various input devices like


keyboard, mouse, digital pens, etc. Input can also be fed through
devices like CD-ROM, pen drive, scanner, etc.
Processing the information

Operations on the input data are carried out based on the


instructions provided in the programs.

Storing the information

After processing, the information gets stored in the primary or


secondary storage area.

Producing output

The processed information and other details are communicated to


the outside world through output devices like monitor, printer, etc.

Computer
Organization and
Architecture Tutorial

Computer Organization and Architecture


Tutorial provides in-depth knowledge of
internal working, structuring, and
implementation of a computer system.

Whereas, Organization defines the way the


system is structured so that all those
catalogued tools can be used properly.

Our Computer Organization and Architecture


Tutorial includes all topics of such as
introduction, ER model, keys, relational
model, join operation, SQL, functional
dependency, transaction, concurrency
control, etc.

ADVERTISEMENT
ADVERTISEMENT

What is Computer
Architecture and
Organization?

In general terms, the architecture of a


computer system can be considered as a
catalogue of tools or attributes that are
visible to the user such as instruction sets,
number of bits used for data, addressing
techniques, etc.

Whereas, Organization of a computer system


defines the way system is structured so that
all those catalogued tools can be used. The
significant components of Computer
organization are ALU, CPU, memory and
memory organization.

ADVERTISEMENT

Von-Neumann Model
Von-Neumann proposed his computer
architecture design in 1945 which was later
known as Von-Neumann Architecture. It
consisted of a Control Unit, Arithmetic, and
Logical Memory Unit (ALU), Registers and
Inputs/Outputs.

Von Neumann architecture is based on the


stored-program computer concept, where
instruction data and program data are stored
in the same memory. This design is still used
in most computers produced today.

A Von Neumann-based
computer:
ADVERTISEMENT
ADVERTISEMENT

o Uses a single processor

o Uses one memory for both instructions


and data.

o Executes programs following the fetch-


decode-execute cycle

Components of Von-
Neumann Model:
ADVERTISEMENT
ADVERTISEMENT

o Central Processing Unit

o Buses
o Memory Unit

Central Processing Unit


ADVERTISEMENT
ADVERTISEMENT

The part of the Computer that performs the


bulk of data processing operations is called
the Central Processing Unit and is referred to
as the CPU.

The Central Processing Unit can also be


defined as an electric circuit responsible for
executing the instructions of a computer
program.

The CPU performs a variety of functions


dictated by the type of instructions that are
incorporated in the computer.

ADVERTISEMENT
ADVERTISEMENT

The major components of CPU are Arithmetic


and Logic Unit (ALU), Control Unit (CU) and
a variety of registers.

Arithmetic and Logic Unit (ALU)

The Arithmetic and Logic Unit (ALU)


performs the required micro-operations for
executing the instructions. In simple words,
ALU allows arithmetic (add, subtract, etc.)
and logic (AND, OR, NOT, etc.) operations to
be carried out.

Control Unit

ADVERTISEMENT
ADVERTISEMENT

The Control Unit of a computer system


controls the operations of components like
ALU, memory and input/output devices.

The Control Unit consists of a program


counter that contains the address of the
instructions to be fetched and an instruction
register into which instructions are fetched
from memory for execution.

Registers

ADVERTISEMENT
ADVERTISEMENT

Registers refer to high-speed storage areas


in the CPU. The data processed by the CPU
are fetched from the registers.

Following is the list of registers that plays a


crucial role in data processing.

Registers Description

MAR (Memory This register holds the


Address Register) memory location of the
data that needs to be
accessed.

MDR (Memory This register holds the


Data Register) data that is being
transferred to or from
memory.

AC (Accumulator) This register holds the


intermediate arithmetic
and logic results.

PC (Program This register contains


Counter) the address of the next
instruction to be
executed.

CIR (Current This register contains


Instruction the current instruction
Register) during processing.

Buses
ADVERTISEMENT
ADVERTISEMENT

Buses are the means by which information is


shared between the registers in a multiple-
register configuration system.

A bus structure consists of a set of common


lines, one for each bit of a register, through
which binary information is transferred one
at a time. Control signals determine which
register is selected by the bus during each
particular register transfer.

Von-Neumann Architecture comprised of


three major bus systems for data transfer.

ADVERTISEMENT
ADVERTISEMENT

Bus Description

Address Address Bus carries the address


Bus of data (but not the data)
between the processor and the
memory.

Data Data Bus carries data between


Bus the processor, the memory unit
and the input/output devices.

Control Control Bus carries


Bus signals/commands from the CPU.

Memory Unit
ADVERTISEMENT
ADVERTISEMENT

A memory unit is a collection of storage cells


together with associated circuits needed to
transfer information in and out of the
storage. The memory stores binary
information in groups of bits called words.
The internal structure of a memory unit is
specified by the number of words it contains
and the number of bits in each word.

Two major types of memories are used in


computer systems:

ADVERTISEMENT
ADVERTISEMENT

1. RAM (Random Access Memory)

2. ROM (Read-Only Memory)

What is computer hardware?

Computer hardware includes the physical


components of a computer. Personal computers
(PCs) are electronic devices that use microchips to
process information and may include desktop
computers, laptops or tablets. Since a computer
comprises many hardware components, they work
together and depend on each other to function
properly.

What are basic components of


computer hardware?
There are several basic components of
computer hardware including:

1. Central processing unit (CPU)

The CPU controls the computer processes and


communicates with the other components of a
personal computer. A computer's CPU may be
one of the most complicated parts of the
computer because of its intricacies. If a
computer is experiencing CPU issues,
a computer technician may start by checking the
fan and cleaning out any dust or debris inside
the machine. Another step a computer
technician may complete is verifying that power
supply cables work. A CPU will not function
properly unless it receives a signal from the
power supply.

2. Motherboard

The motherboard provides the structure for all


other components and connects them, while
also providing a way to distribute power, deliver
information and connect to devices such as a
printer or mouse. It controls how data transfers
and what type of monitor or screen device to
use, for example. It houses the CPU, memory
and secondary storage devices such as hard
drives.

The first thing that a computer technician may


do to troubleshoot any motherboard issues is to
take the PC apart and inspect all the connections
for corrosion. They may also check the power
supply and make sure the computer is receiving
electricity.

3. Random Access Memory (RAM)

RAM is where data lives temporarily while it's


being actively used by programs, such as when a
user launches a computer application. A
technician may know how to identify the type of
RAM in a computer, how to replace it if it's
defective and how to diagnose problems with
copying data from one location in memory to
another.

A technician should have knowledge about the


different RAMs that are available and they may
also know what types of errors might affect a
computer's RAM operation. A technician may
backup all computer files before fixing RAM to
avoid losing critical programs and documents.

4. Video graphics array port

A video graphics array (VGA) port is a video input


that is primarily used on PC monitors.
Troubleshooting a VGA port could include
verifying there isn't a loose connection, faulty
cable or a broken monitor. Another task a
computer technician may do is use compressed
air to spray inside the VGA port to ensure it's
free of dust.

5. Power supply

A power supply provides electricity to all


components of a computer system. Typically, it's
a power cord connected from the back of a PC
tower into an electricity socket. A technician may
troubleshoot the power supply by turning off
the computer, unplugging and detaching the
power supply cord or trying a new cord or
outlet.

6. Cooling fan

Cooling fans are a computer's system to


decrease overheating. Many computers have
more than one cooling fan to help users who
run their computer heavily, such as video
streaming or gaming. A computer technician
may need to fix a computer's cooling fan if a
user notices their computer overheating. They
may check for any damage to the blades and
make sure that they are free from debris.
Replacing computer fans can be a common
troubleshooting solution for a technician.

7. Hard drive

Hard drives are data storage devices used to


store files, programs or other information on a
computer system. They use magnetically coated
discs called hard disks that store digital
representations of information. If a hard drive
fails, a computer technician may suspect a
corrupt hard drive. They may use data recovery
software to repair the computer or may replace
the hard drive.

8. Monitor

A computer monitor is an electronic device that


displays what's what programs are running on
your computer so a user can see. Some
computer technicians may wear anti-static
gloves when handling computer monitors to
avoid static electricity. They may also
troubleshoot monitor issues by disconnecting it
from the computer and trying a new power
cord.

9. Printer

This is a machine that produces copies of text or


images on paper using ink. Popular printers
include laser or inkjet and computer technicians
may be skilled in troubleshooting issues across
multiple brands and varieties. Computer
technicians may service printers including
verifying power is running to the machine. They
may also check to see if the paper tray is full and
ready for printing. Technicians might replace or
refill any ink cartridges and toner.

If the physical printer components are operating


efficiently but the machine still isn't working, a
technician will then troubleshoot software
malfunctions that may occur in the
communication between the computer and the
printer. This requires more expertise to fix since
it involves how the systems interact with each
other rather than physical component failures
on the printer itself.

10. Scanner

A scanner is a device that digitally copies an


image or and makes it available as a file for
access on a computer. If a scanner malfunctions,
a computer technician may remove the cover
and carefully check if it has any damage. If there
are no visible issues, then they may check the
power connection cable. Similar to a printer,
there is computer software that connects the
scanner to the computer, so a technician will
also verify that the software is communicating to
the scanner.

11. Computer mouse

A computer mouse can have a wire or is wireless


and is an input device used to control a cursor
on the computer monitor. A wired computer
mouse has a cord that connects to a USB port on
a computer while a wireless mouse has no
physical connection with a computer system.
Instead, a wireless mouse communicates using
an adapter that is usually plugged into an
available USB port and runs off its own batteries
using Bluetooth technology.

Computer technicians may troubleshoot


computer mouse issues by ensuring it's
connected properly if it has a wire. If the mouse
is wireless, a technician can look to see if they
need batteries and that the wireless connection
is working. Computer technicians can clean both
wired and wireless with cloths to ensure there is
no dust or debris on the sensor on the bottom
of a mouse. If there is, the mouse may not
operate correctly.

Casing

The desktop computer case helps protect the components from


electrical interference, physical damage, and intrusive foreign
objects. The design of the case is important, too, as different
shapes can affect, for better or worse, the airflow through the
unit—which is integral to keeping it cool and operational.

Chipset

A chipset is a set of chips that extends the interfaces


between all of the components of a motherboard. It
includes the buses and interconnects to allow the CPU,
memory, and input/output devices to interact.

real- time clock

A real time clock, or RTC, is a digital clock with a


primary function to keep accurate track of time
even when a power supply is turned off or a
device is placed in low power mode.
BIOS

BIOS (basic input/output system) is the program a


computer’s microprocessor uses to start the
computer system after it is powered on. It also
manages data flow between the computer’s
operating system (OS) and attached devices, such
as the hard disk, video adapter, keyboard, mouse
and printer.

Types of Computer Ports

computer port is a piece of hardware that


allows a computer to connect to other devices,
including accessories, peripheral devices, and
other computers. Ports are standard yet versatile
components found on most modern computer
systems.

Many types of computer ports handle input or


output. Audio and video ports transmit sound
and visuals. Network ports connect a computer
to a broader network or the Internet. USB ports
are compatible with many modern devices like
smartphones and tablets. As with any piece of
technology, it is important to handle ports in a
safe, careful manner.

Audio- and Video-Related Computer


Ports

Audio ports send sound between a computer and its


connected devices, while video ports manage images,
videos, and other visuals. These computer ports can
transmit data from a computer to an external device,
such as speakers or headphones. Audio-visual (A/V)
ports can also send data from external equipment, like
a microphone or camera, to the computer.

USB Ports on a Computer

A rectangular USB-A connector transfers data between


devices.
USB ports, or Universal Serial Bus ports, are the current
standard in data transfer and charging. Cell phones,
tablets, computer peripherals, toys, gaming systems,
appliances, and many other devices use USB
connections. Below are the types of USB connections:

Functions of Different Types of Computer


Connections

Different computer ports have unique functions and


appearances. Distinct ports also interact with the
computer in different ways. The following table
discusses these different ports:

Port Data
Function
Type Direction

Audio Output Send analog or digital data as sound

Display Output Send data to high-resolution displays

VGA Output Send analog video

DVI Output Send lossless digital signals

Send uncompressed video and


HDMI Output
compressed or uncompressed sound

RJ-45 Input & Ethernet connections


Port Data
Function
Type Direction

Output

Input &
RJ-11 Telecommunications
Output

PS/2 Input Connect keyboards and mice

Input &
Serial Send one bit of data at a time
Output

Input &
Parallel High bandwidth transfer
Output

Input &
USB Transfer data and power
Output
Chapter -2 Data Representation

In Computer organization, data refers to the


symbols that are used to represent events, people,
things and ideas.

Data Representation

The data can be represented in the following ways:

Data

Data can be anything like a number, a name, notes


in a musical composition, or the color in a
photograph. Data representation can be referred to
as the form in which we stored the data, processed
it and transmitted it. In order to store the data in
digital format, we can use any device like
computers, smartphones, and iPads. Electronic
circuitry is used to handle the stored data.

Digitization

Digitization is a type of process in which we


convert information like photos, music, number,
text into digital data. Electronic devices are used
to manipulate these types of data. The digital
revolution has evolved with the help of 4 phases,
starting with the big, expensive standalone
computers and progressing to today’s digital
world. All around the world, small and
inexpensive devices are spreading everywhere.

Binary Digits

The binary digits or bits are used to show the


digital data, which is represented by 0 and 1. The
binary digits can be called the smallest unit of
information in a computer. The main use of binary
digit is that it can store the information or data in
the form of 0s and 1s. It contains a value that can
be on/off or true/false. On or true will be
represented by the 1, and off or false will be
represented by the 0. The digital file is a simple
file, which is used to collect data contained by the
storage medium like the flash drive, CD, hard
disk, or DVD.

Bits and Bytes

In the field of digital communication or


computers, bits are the most basic unit of
information or smallest unit of data. It is
short of binary digit, which means it can
contain only one value, either 0 or 1. So bits
can be represented by 0 or 1, - or +, false or
true, off or on, or no or yes. Many
technologies are based on bits and bytes,
which is extensively useful to describe the
network access speed and storage capacity.
The bit is usually abbreviated as a lowercase
b.

In order to execute the instructions and


store the data, the bits are grouped into
multiple bits, which are known as bytes.
Bytes can be defined as a group of eight bits,
and it is usually abbreviated as an uppercase
B. If we have four bytes, it will equal 32 bits
(4*8 = 32), and 10 bytes will equal 80 bits
(8*10 = 80).

Uses

Bits are used for data rates like speeds while


movie download, speed while internet
connection, etc. Bytes are used to get the
storage capacity and file sizes. When we are
reading something related to digital devices,
it will be frequently encountered references
like 90 kilobits per second, 1.44 megabytes,
2.8 gigahertz, and 2 terabytes. To quantify
digital data, we have many options such as
Kilo, Mega, Giga, Tera and many more
similar terms, which are described as
follows:

104 KB: Kb is also called a kilobyte or Kbyte.


It is mostly used while referring to the size of
small computer files.

56 Kbps: Kbps is also called kilobit, Kbit or Kb.


The 56 kbps means 56 kilobits per second
which are used to show the slow data rates.
If our internet speed is 56 kbps, we have to
face difficulty while connecting more than
one device, buffering while streaming videos,
slow downloading, and many other internet
connectivity problems.

50 Mbps: Mbps is also called Megabit, MB or


Mbit. The 50 Mbps means 50 Megabit per
second, which are used to show the faster
data rates. If our internet speed is 50 Mbps,
we will experience online activity without any
buffering, such as online gaming,
downloading music, streaming HD, web
browsing, etc. 50 Mbps or more than that
will be known as fast internet speed. With
the help of fast speed, we can easily handle
more than one online activity for more than
one user at a time without major
interruptions in services.

3.2 MB: 3.2 MB is also called Megabyte, MB or


MByte. It is used when we are referring to
the size of files, which contains videos and
photos.

100 Gbit: 100 Gbit is also called Gigabit or GB.


It is used to show the really fast network
speeds.

16 GB: 16 GB is also called Gigabyte, GB or


GByte. It is used to show the storage
capacity.

Signed and Unsigned


Binary Numbers
The integer variables are represented in a
signed and unsigned manner. The positive
and negative values are differentiated by
using the sign flag in signed numbers. The
unsigned numbers do not use any flag for
the sign, i.e., only positive numbers can be
stored by the unsigned numbers.

It is very easy to represent positive and


negative numbers in our day to day life. We
represent the positive numbers without
adding any sign before them and the
negative number with - (minus) sign before
them. But in the digital system, it is not
possible to use negative sign before them
because the data is in binary form in digital
computers. For representing the sign in
binary numbers, we require a special
notation.

Binary Numbers
Representation
ADVERTISEMENT

ADVERTISEMENT
Our computer can understand only (0, 1)
language. The binary numbers are
represented in both ways, i.e., signed and
unsigned. The positive numbers are
represented in both ways- signed and
unsigned, but the negative numbers can only
be described in a signed way. The difference
between unsigned and signed numbers is
that unsigned numbers do not use any sign
bit for positive and negative numbers
identification, but the signed number used.

Unsigned Numbers
ADVERTISEMENT

ADVERTISEMENT

As we already know, the unsigned numbers


don't have any sign for representing negative
numbers. So the unsigned numbers are
always positive. By default, the decimal
number representation is positive. We
always assume a positive sign in front of
each decimal digit.

There is no sign bit in unsigned binary


numbers so it can only represent its
magnitude. In zero and one, zero is an
unsigned binary number. There is only one
zero (0) in this representation, which is
always positive. Because of one unique
binary equivalent form of a number in
unsigned number representation, it is known
as unambiguous representation technique.
The range of the unsigned binary numbers
starts from 0 to (2n-1).

ADVERTISEMENT

ADVERTISEMENT

Example: Represent the decimal number 102


in unsigned binary numbers.

ADVERTISEMENT

ADVERTISEMENT

We will change this decimal number into


binary, which has the only magnitude of the
given name.

Decimal Operation Result Remainder

102 102/2 51 0

51 51/2 25 1

25 25/2 12 1

12 12/2 6 0

6 6/2 3 0
3 3/2 1 1

1 1/2 0 1

So the binary number of (102) 10 is


(1100110)2, a 7-bit magnitude of the decimal
number 102.

ADVERTISEMENT

ADVERTISEMENT

Signed Numbers

The signed numbers have a sign bit so that it


can differentiate positive and negative
integer numbers. The signed binary number
technique has both the sign bit and the
magnitude of the number. For representing
the negative decimal number, the
corresponding symbol in front of the binary
number will be added.

The signed numbers are represented in three


ways. The signed bit makes two possible
representations of zero (positive (0) and
negative (1)), which is an ambiguous
representation. The third representation is
2's complement representation in which no
double representation of zero is possible,
which makes it unambiguous representation.
There are the following types of
representation of signed binary numbers:

ADVERTISEMENT

ADVERTISEMENT

1. Sign-Magnitude form
In this form, a binary number has a bit for
a sign symbol. If this bit is set to 1, the
number will be negative else the number
will be positive if it is set to 0. Apart from
this sign-bit, the n-1 bits represent the
magnitude of the number.

2. 1's Complement
By inverting each bit of a number, we can
obtain the 1's complement of a number.
The negative numbers can be represented
in the form of 1's complement. In this
form, the binary number also has an extra
bit for sign representation as a sign-
magnitude form.

3. 2's Complement
By inverting each bit of a number and
adding plus 1 to its least significant bit, we
can obtain the 2's complement of a
number. The negative numbers can also be
represented in the form of 2's
complement. In this form, the binary
number also has an extra bit for sign
representation as a sign-magnitude form.

ADVERTISEMENT
ADVERTISEMENT

Floating-Point Representation

The floating-point representation can implement


operations for high range values. The numerical evaluations
are carried out using floating-point values. It can create
calculations easy, scientific numbers are described as follows

The number 5,600,000 can be described as 0.56 * 107.

Therefore, 0.56 is the mantissa and 7 is the value of the


exponent.

Binary numbers can also be described in exponential form.


The description of binary numbers in the exponential form is
called floating-point representation. The floating-point
representation breaks the number into two parts, the left-
hand side is a signed, fixed-point number known as a
mantissa and the right-hand side of the number is known as
the exponent. The floating-point values are also authorized
with a sign; 0 denoting the positive value and 1 denoting the
negative value.

The general structure of floating-point representation of a


binary number –

X=(x0*20+x1*21+x2*22±−−∓b−(n−1)*2−(n−1) )
Mantissa*2Exponent

In the following syntax, the decimal point is transferred left


for negative exponents of two and right for positive
exponents of two. Both the mantissa and the exponent are
signed values enabling negative numbers and negative
exponents commonly.

Example – Convert 111101.1000110 into floating-point value.

111101.1000110 = 1.111011000110 * 25Converted to


floating-point value

→ Denotes negative sign value

In this example, the integer value is converted to a floating-


point value by changing the radix point next to the signed
integer and scaling up the number to the exponential form by
multiplying the value with the base 2. The value remains
unaltered and this phase is known as the normalized method.

BCD

Binary Coded Decimal, or BCD, is another process for


converting decimal numbers into their binary equivalents.

It is a form of binary encoding where each digit in a decimal


number is represented in the form of bits.

This encoding can be done in either 4-bit or 8-bit (usually 4-


bit is preferred).

It is a fast and efficient system that converts the decimal


numbers into binary numbers as compared to the existing
binary system.

These are generally used in digital displays where is the


manipulation of data is quite a task.

Thus BCD plays an important role here because the


manipulation is done treating each digit as a separate single
sub-circuit.

The BCD equivalent of a decimal number is written by


replacing each decimal digit in the integer and fractional
parts with its four bit binary equivalent.the BCD code is
more precisely known as 8421 BCD code , with 8,4,2 and 1
representing the weights of different bits in the four-bit
groups, Starting from MSB and proceeding towards LSB. This
feature makes it a weighted code , which means that each
bit in the four bit group representing a given decimal digit
has an assigned weight.

Many decimal values, have an infinite place-value


representation in binary but have a finite place-value in
binary-coded decimal. For example, 0.2 in binary
is .001100… and in BCD is 0.0010. It avoids fractional errors
and is also used in huge financial calculations.

Consider the following truth table and focus on how are


these represented.

Truth Table for Binary Coded Decimal

DECIMAL NUMBER BCD

0 0000

1 0001

2 0010

3 0011
4 0100

5 0101

6 0110

7 0111

8 1000

9 1001

In the BCD numbering system, the given decimal number is


segregated into chunks of four bits for each decimal digit
within the number. Each decimal digit is converted into its
direct binary form (usually represented in 4-bits).

For example:

1. Convert (123)10 in BCD

From the truth table above,

1 -> 0001

2 -> 0010

3 -> 0011

Thus, BCD becomes -> 0001 0010 0011

2. Convert (324)10 in BCD

(324)10 -> 0011 0010 0100 (BCD)


Again from the truth table above,

3 -> 0011

2 -> 0010

4 -> 0100

Thus, BCD becomes -> 0011 0010 0100


Chapter -3 Instruction format

Computer Organization | Instruction Formats (Zero, One, Two


and Three Address Instruction)

In computer organization, instruction formats refer to the


way instructions are encoded and represented in machine
language. There are several types of instruction formats,
including zero, one, two, and three-address instructions.

Each type of instruction format has its own advantages and


disadvantages in terms of code size, execution time, and
flexibility. Modern computer architectures typically use a
combination of these formats to provide a balance between
simplicity and power.

What are the Different Types of Filed in Instruction?

A computer performs a task based on the instruction


provided. Instruction in computers comprises groups called
fields. These fields contain different information for
computers everything is in 0 and 1 so each field has different
significance based on which a CPU decides what to perform.
The most common fields are:

The operation field specifies the operation to be performed


like addition.

Address field which contains the location of the operand, i.e.,


register or memory location.
Mode field which specifies how operand is to be founded.

Instruction is of variable length depending upon the number


of addresses it contains. Generally, CPU organization is of
three types based on the number of address fields:

Single Accumulator organization

General register organization

Stack organization

In the first organization, the operation is done involving a


special register called the accumulator. In the second multiple
registers are used for the computation purpose. In the third
organization the work on stack basis operation due to which
it does not contain any address field. Only a single
organization doesn’t need to be applied, a blend of various
organizations is mostly what we see generally.

Types of Instructions
Based on the number of addresses,
instructions are classified as:
NOTE: We will use the X = (A+B)*(C+D)
expression to showcase the procedure.

Zero Address Instructions

These instructions do not specify any


operands or addresses. Instead, they operate
on data stored in registers or memory
locations implicitly defined by the instruction.
For example, a zero-address instruction might
simply add the contents of two registers
together without specifying the register
names.
Zero Address Instruction

A stack-based computer does not use the


address field in the instruction. To evaluate an
expression first it is converted to reverse
Polish Notation i.e. Postfix Notation.
Expression: X = (A+B)*(C+D)
Postfixed : X = AB+CD+*
TOP means top of stack
M[X] is any memory location

PUSH A TOP = A
PUSH B TOP = B
ADD TOP = A+B
PUSH C TOP = C
PUSH D TOP = D
ADD TOP = C+D
MUL TOP = (C+D)*(A+B)
POP X M[X] = TOP
One Address Instructions

These instructions specify one operand or


address, which typically refers to a memory
location or register. The instruction operates
on the contents of that operand, and the
result may be stored in the same or a different
location. For example, a one-address
instruction might load the contents of a
memory location into a register.

This uses an implied ACCUMULATOR


register for data manipulation. One operand is
in the accumulator and the other is in the
register or memory location. Implied means
that the CPU already knows that one operand
is in the accumulator so there is no need to
specify it.

One Address Instruction


Expression: X = (A+B)*(C+D)
AC is accumulator
M[] is any memory location
M[T] is temporary location

LOAD A AC = M[A]
ADD B AC = AC + M[B]
STORE T M[T] = AC
LOAD C AC = M[C]
ADD D AC = AC + M[D]
MUL T AC = AC * M[T]
STORE X M[X] = AC
Two Address Instructions

These instructions specify two operands or


addresses, which may be memory locations
or registers. The instruction operates on the
contents of both operands, and the result may
be stored in the same or a different location.
For example, a two-address instruction might
add the contents of two registers together and
store the result in one of the registers.

This is common in commercial computers.


Here two addresses can be specified in the
instruction. Unlike earlier in one address
instruction, the result was stored in the
accumulator, here the result can be stored at
different locations rather than just
accumulators, but require more number of bit
to represent the address.

Two Address Instruction

Here destination address can also contain an


operand.
Expression: X = (A+B)*(C+D)
R1, R2 are registers
M[] is any memory location
MOV R1, A R1 = M[A]
ADD R1, B R1 = R1 + M[B]
MOV R2, C R2 = M[C]
ADD R2, D R2 = R2 + M[D]
MUL R1, R2 R1 = R1 * R2
MOV X, R1 M[X] = R1
Three Address Instructions

These instructions specify three operands or


addresses, which may be memory locations
or registers. The instruction operates on the
contents of all three operands, and the result
may be stored in the same or a different
location. For example, a three-address
instruction might multiply the contents of two
registers together and add the contents of a
third register, storing the result in a fourth
register.

This has three address fields to specify a


register or a memory location. Programs
created are much short in size but number of
bits per instruction increases. These
instructions make the creation of the program
much easier but it does not mean that
program will run much faster because now
instructions only contain more information but
each micro-operation (changing the content of
the register, loading address in the address
bus etc.) will be performed in one cycle only.

Three Address Instruction


Expression: X = (A+B)*(C+D)
R1, R2 are registers
M[] is any memory location

ADD R1, A, B R1 = M[A] + M[B]


ADD R2, C, D R2 = M[C] + M[D]
MUL X, R1, R2 M[X] = R1 * R2
Instruction Set
Completeness

A set of instructions is
said to be complete if the
computer includes a
sufficient number of
instructions in each of the
following categories:

Arithmetic, logical and


shift instructions

A set of instructions for


moving information to and
from memory and
processor registers.

Instructions which
controls the program
together with instructions
that check status
conditions.

Input and Output


instructions

Arithmetic, logic and shift


instructions provide
computational
capabilities for
processing the type of
data the user may wish to
employ.

A huge amount of binary


information is stored in
the memory unit, but all
computations are done in
processor registers.
Therefore, one must
possess the capability of
moving information
between these two units.

Program control
instructions such as
branch instructions are
used change the
sequence in which the
program is executed.

Input and Output


instructions act as an
interface between the
computer and the user.
Programs and data must
be transferred into
memory, and the results
of computations must be
transferred back to the
user.

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:

1. Fetch instruction from memory.

2. Decode the instruction.


3. Read the effective address from
memory.

4. Execute the instruction.

You might also like