You are on page 1of 33

YEAR : 2021-22

Computer System Organization


{BTCS103N}
Branch :- B.tech (CSE)
st
Sem – 1

Submitted By: Chirag joshi Submitted To:


Enrollment No :21100BTCSE09815 SUNNY BAGGA
Experiment 1:
Objective: Study Of Peripherals
Components Of A Computer System

● WHAT IS PERIPHERALS ?

A peripheral is a “device that is used to put information into or get information out of
the computer.

● Different types of peripherals.


• Input, used to interact with, or send data to the computer (mouse,
keyboards, etc.)
• Output, which provides output to the user from the computer (monitors,
printers, etc.)
• Storage, which stores data processed by the computer (hard drives, flash
drives, etc.)

A peripheral device is generally defined as any auxiliary device such as a


computer mouse or keyboard, that connects to and works with the computer in some
way. Other examples of peripherals are expansion cards, graphics cards, image
scanners, tape drives, microphones, loudspeakers, webcams, and digital cameras.

● Types Of Common Peripheral Devices


Input Devices:
⮚ Keyboard
⮚ Computer mouse
⮚ Graphic tablet
⮚ Touchscreen
⮚ Barcode reader
⮚ Image scanner
⮚ Microphone
⮚ Webcam
⮚ Game controller
⮚ Light pen
⮚ Scanner
⮚ Digital camera

Output Devices:

⮚ Speaker
⮚ Monitor
⮚ Printer
⮚ Headphone
⮚ Projector

Storage Devices:

⮚ Pen Drive
⮚ Hard Drive
⮚ USB
⮚ DVD
⮚ Floppy Disk
⮚ Solid State Drive

Input Devices:

In computing, an input device is a piece of equipment used to provide data and control
signals to an information processing system, such as a computer or information
appliance. Examples of input devices include keyboards, mouse, scanners, cameras,
joysticks, and microphones.

Many input devices can be classified according to:

⮚ Modality of input (e.g. mechanical motion, audio, visual, etc.)


⮚ The input is discrete (e.g. key presses) or continuous (e.g. a
mouse’s position, though digitized into a discrete quantity, is
fast enough to be considered continuous)

Pointing devices, which are input devices used to specify a position in


space, can further be classified according to:

⮚ Whether the input is direct or indirect. With direct input, the


input space coincides with the display space, i.e. pointing is
done in the space where visual feedback or the pointer appears.
Touchscreens and light pens involve direct input. Examples
involving indirect input include the mouse and trackball.
⮚ Whether the positional information is absolute (e.g. on a touch
screen) or relative (e.g. with a mouse that can be lifted and
repositioned) Keyboard
A keyboard is a human interface device which is represented as a layout of buttons.
Each button, or key, can be used to either input a linguistic character to a computer, or
to call upon a particular function of the computer. They act as the main text entry
interface for most users. Traditional keyboards use spring-based buttons, though newer
variations employ virtual keys, or even projected keyboards. It is typewriter like device
composed of a matrix of switches

Pointing Devices:
A pointing device is any human interface device that allows a user to input
spatial data to a computer. In the case of mice and touchpads, this is usually achieved
by detecting movement across a physical surface. Analog devices, such as 3D mice,
joysticks, or pointing sticks, function by reporting their angle of deflection.
Movements of the pointing device are echoed on the screen by movements of the
pointer, creating a simple, intuitive way to navigate a computer’s graphical user
interface (GUI).

Composite Devices :
Input devices, such as buttons and joysticks, can be combined on a single
physical device that could be thought of as a composite device. Many gaming
devices have controllers like this. Technically mice are composite devices, as they
both track movement and provide buttons for clicking, but composite devices are
generally considered to have more than two different forms of input.
⮚ Game controller
⮚ Gamepad (or joypad)
⮚ Paddle (game controller)
⮚ Jog dial/shuttle (or knob)

Imaging and Input Devices:

Video input devices are used to digitize images or video from the outside
world into the computer. The information can be stored in a multitude of formats
depending on the user’s requirement.

⮚ Digital camera
⮚ Digital camcorder
⮚ Portable media player
⮚ Webcam
⮚ Microsoft Kinect Sensor
⮚ Image scanner
⮚ Fingerprint scanner
⮚ Barcode reader
⮚ 3D scanner
⮚ Laser rangefinder
⮚ Eye gaze tracker

Medical Imaging :

⮚ Computed tomography
⮚ Magnetic resonance imaging
⮚ Positron emission tomography
⮚ Medical ultrasonography

Audio Input Devices :

Audio input devices are used to capture sound. In some cases, an audio
output device can be used as an input device, in order to capture produced sound.

⮚ Microphones
⮚ MIDI keyboard or other digital musical instrument

Output Devices:
An output device is any piece of computer hardware equipment used to
communicate the results of data processing carried out by an information processing
system (such as a computer) which converts the electronically generated information
into human-readable form.

Display Devices:

A display device is an output device that visually conveys text, graphics,


and video information. Information shown on a display device is called soft
copybecause the information exists electronically and is displayed for a temporary
period of time. Display devices include CRT monitors, LCD monitors and displays,
gas plasma monitors, and televisions.
Input/Output :

Inputs are the signals or data received by the system, and outputs are the signals or
data sent from it.

There are many input and output devices such as multifunction printers and
computer-based navigation systems that are used for specialised or unique
applications. In computing, input/output refers to the communication between an
information processing system (such as a computer), and the outside world. Inputs
are the signals or data received by the system, and outputs are the signals or data sent
from it.

Examples:
These examples of output devices also include input/output devices.
Printers and visual displays are the most common type of output device for
interfacing to people, but voice is becoming increasingly available.[9]

⮚ Speakers
⮚ Headphones
⮚ Screen (Monitor)
⮚ Printer
⮚ Automotive navigation system
⮚ Projector
⮚ Television

Computer Memory :
In computing, memory refers to the devices used to store information for
use in a computer. The term primary memory is used for storage systems which
function at high-speed (i.e. RAM), as a distinction from secondary memory, which
provides program and data storage that is slow to access but offer higher memory
capacity. If needed, primary memory can be stored in secondary memory, through a
memory management technique called “virtual memory.” An archaic synonym for
memory is store.

Volatile Memory
DDR-SD-RAM, SD-RAM and two older forms of RAM.

Volatile memory is computer memory that requires power to maintain the


stored information. Most modernsemiconductor volatile memory is either Static
RAM (see SRAM) or dynamic RAM (see DRAM). SRAM retains its contents as
long as the power is connected and is easy to interface to but uses six transistors per
bit. Dynamic RAM is more complicated to interface to and control and needs regular
refresh cycles to prevent its contents being lost. However, DRAM uses only one
transistor and a capacitor per bit, allowing it to reach much higher densities and, with
more bits on a memory chip, be much cheaper per bit. SRAM is not worthwhile for
desktop system memory, where DRAM dominates, but is used for their cache
memories. SRAM is commonplace in small embedded systems, which might only
need tens of kilobytes or less. Forthcoming volatile memory technologies that hope
to replace or compete with SRAM and DRAM include Z-RAM, TTRAM, A-RAM
and ETA RAM.

Non-Volatile Memory:

Solid-state drives are one of the latest forms of non-volatile memory.

Non-volatile memory is computer memory that can retain the stored information even
when not powered. Examples of non-volatile memory include read-only
memory (see ROM), flash memory, most types of magnetic computer storage
devices (e.g. hard disks, floppy discs and magnetic tape), optical discs, and early
computer storage methods such as paper tape and punched cards. Forthcoming non-
volatile memory technologies include FeRAM, CBRAM,PRAM, SONOS, RRAM,
Racetrack memory, NRAM and Millipede.

Experiment 2:
Objective: Write a C program for sum of
two Binary numbers.

Code:
#include <stdio.h>
int main()
{
long binary1, binary2;
int i = 0, remainder = 0, sum[20];
printf("Enter the first binary number: ");
scanf("%ld", &binary1);
printf("Enter the second binary number: ");
scanf("%ld", &binary2);
while (binary1 != 0 || binary2 != 0)
{
sum[i++] =(binary1 % 10 + binary2 % 10 + remainder) % 2;
remainder =(binary1 % 10 + binary2 % 10 + remainder) / 2;
binary1 = binary1 / 10;
binary2 = binary2 / 10;
}
if (remainder != 0)
sum[i++] = remainder;
--i;
printf("Sum of two binary numbers: ");
while (i >= 0)
printf("%d", sum[i--]);
return 0;
}

Output:
Experiment 3:
Objective: Write a C program for
multiplication of two Binary numbers.
Code:
#include <stdio.h>
int binaryproduct(int, int);
int main()
{
long binary1, binary2, multiply = 0;
int digit, factor = 1;

printf("Enter the first binary number: ");


scanf("%ld", &binary1);
printf("Enter the second binary number: ");
scanf("%ld", &binary2);
while (binary2 != 0)
{
digit = binary2 % 10;
if (digit == 1)
{
binary1 = binary1 * factor;
multiply = binaryproduct(binary1, multiply);
}
else
binary1 = binary1 * factor;
binary2 = binary2 / 10;
factor = 10;
}
printf("Product of two binary numbers: %ld", multiply);
return 0;
}

int binaryproduct(int binary1, int binary2)


{
int i = 0, remainder = 0, sum[20];
int binaryprod = 0;

while (binary1 != 0 || binary2 != 0)


{
sum[i++] =(binary1 % 10 + binary2 % 10 + remainder) % 2;
remainder =(binary1 % 10 + binary2 % 10 + remainder) / 2;
binary1 = binary1 / 10;
binary2 = binary2 / 10;
}
if (remainder != 0)
sum[i++] = remainder;
--i;
while (i >= 0)
binaryprod = binaryprod * 10 + sum[i--];
return binaryprod;
}
Output:

Experiment 4:
Objective: Write a C program to implement
Booth’s Algorithm Multiplication.
Code:
#include <stdio.h>
#include <math.h>

int a = 0,b = 0, c = 0, a1 = 0, b1 = 0, com[5] = { 1, 0, 0, 0, 0};


int anum[5] = {0}, anumcp[5] = {0}, bnum[5] = {0};
int acomp[5] = {0}, bcomp[5] = {0}, pro[5] = {0}, res[5] = {0};

void binary(){
a1 = fabs(a);
b1 = fabs(b);
int r, r2, i, temp;
for (i = 0; i < 5; i++){
r = a1 % 2;
a1 = a1 / 2;
r2 = b1 % 2;
b1 = b1 / 2;
anum[i] = r;
anumcp[i] = r;
bnum[i] = r2;
if(r2 == 0){
bcomp[i] = 1;
}
if(r == 0){
acomp[i] =1;
}
}
//part for two's complementing
c = 0;
for ( i = 0; i < 5; i++){
res[i] = com[i]+ bcomp[i] + c;
if(res[i] >= 2){
c = 1;
}
else
c = 0;
res[i] = res[i] % 2;
}
for (i = 4; i >= 0; i--){
bcomp[i] = res[i];
}
//in case of negative inputs
if (a < 0){
c = 0;
for (i = 4; i >= 0; i--){
res[i] = 0;
}
for ( i = 0; i < 5; i++){
res[i] = com[i] + acomp[i] + c;
if (res[i] >= 2){
c = 1;
}
else
c = 0;
res[i] = res[i]%2;
}
for (i = 4; i >= 0; i--){
anum[i] = res[i];
anumcp[i] = res[i];
}

}
if(b < 0){
for (i = 0; i < 5; i++){
temp = bnum[i];
bnum[i] = bcomp[i];
bcomp[i] = temp;
}
}
}
void add(int num[]){
int i;
c = 0;
for ( i = 0; i < 5; i++){
res[i] = pro[i] + num[i] + c;
if (res[i] >= 2){
c = 1;
}
else{
c = 0;
}
res[i] = res[i]%2;
}
for (i = 4; i >= 0; i--){
pro[i] = res[i];
printf("%d",pro[i]);
}
printf(":");
for (i = 4; i >= 0; i--){
printf("%d", anumcp[i]);
}
}
void arshift(){//for arithmetic shift right
int temp = pro[4], temp2 = pro[0], i;
for (i = 1; i < 5 ; i++){//shift the MSB of product
pro[i-1] = pro[i];
}
pro[4] = temp;
for (i = 1; i < 5 ; i++){//shift the LSB of product
anumcp[i-1] = anumcp[i];
}
anumcp[4] = temp2;
printf("\nAR-SHIFT: ");//display together
for (i = 4; i >= 0; i--){
printf("%d",pro[i]);
}
printf(":");
for(i = 4; i >= 0; i--){
printf("%d", anumcp[i]);
}
}

void main(){
int i, q = 0;
printf("\t\tBOOTH'S MULTIPLICATION ALGORITHM");
printf("\nEnter two numbers to multiply: ");
printf("\nBoth must be less than 16");
//simulating for two numbers each below 16
do{
printf("\nEnter A: ");
scanf("%d",&a);
printf("Enter B: ");
scanf("%d", &b);
}while(a >=16 || b >=16);

printf("\nExpected product = %d", a * b);


binary();
printf("\n\nBinary Equivalents are: ");
printf("\nA = ");
for (i = 4; i >= 0; i--){
printf("%d", anum[i]);
}
printf("\nB = ");
for (i = 4; i >= 0; i--){
printf("%d", bnum[i]);
}
printf("\nB'+ 1 = ");
for (i = 4; i >= 0; i--){
printf("%d", bcomp[i]);
}
printf("\n\n");
for (i = 0;i < 5; i++){
if (anum[i] == q){//just shift for 00 or 11
printf("\n-->");
arshift();
q = anum[i];
}
else if(anum[i] == 1 && q == 0){//subtract and shift for 10
printf("\n-->");
printf("\nSUB B: ");
add(bcomp);//add two's complement to implement subtraction
arshift();
q = anum[i];
}
else{//add ans shift for 01
printf("\n-->");
printf("\nADD B: ");
add(bnum);
arshift();
q = anum[i];
}
}

printf("\nProduct is = ");
for (i = 4; i >= 0; i--){
printf("%d", pro[i]);
}
for (i = 4; i >= 0; i--){
printf("%d", anumcp[i]);
}
}

Output:
Experiment 5:
Objective: Write the working of 8085
simulator GNUsim8085 and basic
architecture of 8085 along with small
introduction.

8085 is pronounced as "eighty-eighty-five" microprocessor. It is an 8-bit


microprocessor designed by Intel in 1977 using NMOS technology.
It has the following configuration −

● 8-bit data bus


● 16-bit address bus, which can address upto 64KB
● A 16-bit program counter
● A 16-bit stack pointer
● Six 8-bit registers arranged in pairs: BC, DE, HL
● Requires +5V supply to operate at 3.2 MHZ single phase clock
It is used in washing machines, microwave ovens, mobile phones, etc.
8085 Microprocessor – Functional Units:
8085 consists of the following functional units −
Accumulator:
It is an 8-bit register used to perform arithmetic, logical, I/O & LOAD/STORE
operations. It is connected to internal data bus & ALU.
Arithmetic and logic unit:
As the name suggests, it performs arithmetic and logical operations like Addition,
Subtraction, AND, OR, etc. on 8-bit data.
General purpose register:
There are 6 general purpose registers in 8085 processor, i.e. B, C, D, E, H & L.
Each register can hold 8-bit data.
These registers can work in pair to hold 16-bit data and their pairing combination
is like B-C, D-E & H-L.
Program counter:
It is a 16-bit register used to store the memory address location of the next
instruction to be executed. Microprocessor increments the program whenever an
instruction is being executed, so that the program counter points to the memory
address of the next instruction that is going to be executed.
Stack pointer:
It is also a 16-bit register works like stack, which is always
incremented/decremented by 2 during push & pop operations.
Temporary register:
It is an 8-bit register, which holds the temporary data of arithmetic and logical
operations.
Flag register:
It is an 8-bit register having five 1-bit flip-flops, which holds either 0 or 1
depending upon the result stored in the accumulator.
These are the set of 5 flip-flops −

● Sign (S)
● Zero (Z)
● Auxiliary Carry (AC)
● Parity (P)
● Carry (C)
Its bit position is shown in the following table −

D7 D6 D5 D4 D3 D2

S Z AC P

Instruction register and decoder:


It is an 8-bit register. When an instruction is fetched from memory then it is stored
in the Instruction register. Instruction decoder decodes the information present in
the Instruction register.
Timing and control unit:
It provides timing and control signal to the microprocessor to perform operations.
Following are the timing and control signals, which control external and internal
circuits −

● Control Signals: READY, RD’, WR’, ALE


● Status Signals: S0, S1, IO/M’
● DMA Signals: HOLD, HLDA
● RESET Signals: RESET IN, RESET OUT
Interrupt control:
As the name suggests it controls the interrupts during a process. When a
microprocessor is executing a main program and whenever an interrupt occurs,
the microprocessor shifts the control from the main program to process the
incoming request. After the request is completed, the control goes back to the
main program.
There are 5 interrupt signals in 8085 microprocessor: INTR, RST 7.5, RST 6.5,
RST 5.5, TRAP.
Serial Input/output control:
It controls the serial data communication by using these two instructions: SID
(Serial input data) and SOD (Serial output data).
Address buffer and address-data buffer:
The content stored in the stack pointer and program counter is loaded into the
address buffer and address-data buffer to communicate with the CPU. The
memory and I/O chips are connected to these buses; the CPU can exchange the
desired data with the memory and I/O chips.
Address bus and data bus:
Data bus carries the data to be stored. It is bidirectional, whereas address bus
carries the location to where it should be stored and it is unidirectional. It is used
to transfer the data & Address I/O devices.
8085 Architecture:
We have tried to depict the architecture of 8085 with this following image −
Experiment 6:
Objective: Study the complete instruction set
of 8085 and write the instructions in the
instruction set of 8085 along with example.

Instruction sets are instruction codes to perform some task. It is classified into five
categories.

S.No Instruction & Description


.

Control Instructions
1
Following is the table showing the list of Control instructions with their
meanings.

Logical Instructions
2 Following is the table showing the list of Logical instructions with their
meanings.
Branching Instructions
3 Following is the table showing the list of Branching instructions with
their meanings.

Arithmetic Instructions
4 Following is the table showing the list of Arithmetic instructions with
their meanings.

Data Transfer Instructions


5 Following is the table showing the list of Data-transfer instructions with
their meanings.

8085 – Demo Programs


Now, let us take a look at some program demonstrations using the above
instructions −
Adding Two 8-bit Numbers
Write a program to add data at 3005H & 3006H memory location and store the
result at 3007H memory location.
Problem demo −
(3005H) = 14H
(3006H) = 89H
Result −
14H + 89H = 9DH
The program code can be written like this −
LXI H 3005H : "HL points 3005H"
MOV A, M : "Getting first operand"
INX H : "HL points 3006H"
ADD M : "Add second operand"
INX H : "HL points 3007H"
MOV M, A : "Store result at 3007H"
HLT : "Exit program"
Exchanging the Memory Locations
Write a program to exchange the data at 5000M& 6000M memory location.
LDA 5000M : "Getting the contents at5000M location into accumulator"
MOV B, A : "Save the contents into B register"
LDA 6000M : "Getting the contents at 6000M location into accumulator"
STA 5000M : "Store the contents of accumulator at address 5000M"
MOV A, B : "Get the saved contents back into A register"
STA 6000M : "Store the contents of accumulator at address 6000M"
Arrange Numbers in an Ascending Order
Write a program to arrange first 10 numbers from memory address 3000H in an
ascending order.
MVI B, 09 :"Initialize counter"
START :"LXI H, 3000H: Initialize memory pointer"
MVI C, 09H :"Initialize counter 2"
BACK: MOV A, M :"Get the number"
INX H :"Increment memory pointer"
CMP M :"Compare number with next number"
JC SKIP :"If less, don’t interchange"
JZ SKIP :"If equal, don’t interchange"
MOV D, M
MOV M, A
DCX H
MOV M, D
INX H :"Interchange two numbers"
SKIP:DCR C :"Decrement counter 2"
JNZ BACK :"If not zero, repeat"
DCR B :"Decrement counter 1"
JNZ START
HLT :"Terminate program execution"
Experiment 7:
Objective: Write a C program to implement
Restoring Division Algorithm
Code:-
#include<stdlib.h>
#include<stdio.h>
int acum[100]={0} ;
void add(int acum[],int b[],int n);
int q[100],b[100];
int main()
{
int x,y;
printf("Enter the Number :");
scanf("%d%d",&x,&y);
int i=0;
while(x>0||y>0)
{
if(x>0)
{
q[i]=x%2;
x=x/2;
}
else
{
q[i]=0;
}
if(y>0)
{
b[i]=y%2;
y=y/2;
}
else
{
b[i]=0;
}
i++;
}

int n=i;
int bc[50];
printf("\n");
for(i=0;i<n;i++)
{
if(b[i]==0)
{
bc[i]=1;
}
else
{
bc[i]=0;
}
}
bc[n]=1;
for(i=0;i<=n;i++)
{
if(bc[i]==0)
{
bc[i]=1;
i=n+2;
}
else
{
bc[i]=0;
}
}
int l;
b[n]=0;
int k=n;
int n1=n+n-1;
int j,mi=n-1;
for(i=n;i!=0;i--)
{
for(j=n;j>0;j--)
{
acum[j]=acum[j-1];

}
acum[0]=q[n-1];
for(j=n-1;j>0;j--)
{
q[j]=q[j-1];
}

add(acum,bc,n+1);
if(acum[n]==1)
{
q[0]=0;
add(acum,b,n+1);
}
else
{
q[0]=1;
}
}
printf("\nQuoient : ");

for( l=n-1;l>=0;l--)
{
printf("%d",q[l]);

}
printf("\nRemainder : ");
for( l=n;l>=0;l--)
{
printf("%d",acum[l]);
}
return 0;
}
void add(int acum[],int bo[],int n)
{
int i=0,temp=0,sum=0;
for(i=0;i<n;i++)
{
sum=0;
sum=acum[i]+bo[i]+temp;
if(sum==0)
{
acum[i]=0;
temp=0;
}
else if (sum==2)
{
acum[i]=0;
temp=1;
}
else if(sum==1)
{
acum[i]=1;
temp=0;
}
else if(sum==3)
{
acum[i]=1;
temp=1;
}
}
}
Output:-
Experiment 8:-
Objective: Write an assembly language code
in GNU8085 to implement data transfer
instruction.
Code:

LDA 0000
MOV B , A
LDA 0001
HLT
Output:-

Experiment 9:-
Objective : Write an assembly language code
in GNU8085 to store number in reverse
order.
Code:-
LDA 0002
RLC
RLC
RLC
RLC
STA 0003
HLT

Output:-

Experiment 10:-
Objective: Write an assembly language code
in GNU8085 to add two 8 bit numbers stored
in memory and also storing the carry.
Code:-

LDA 0000
MOV B,A
LDA 0001
ADD B
STA 0002
HLT

Output:-

You might also like