0% found this document useful (0 votes)
8 views65 pages

BTCS103N - Lab Manual

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views65 pages

BTCS103N - Lab Manual

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Shri Vaishnav Vidyapeeth Vishwavidyalaya, Indore

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering

LAB MANUAL
COMPUTER SYSTEM ORGANIZATION
BTCS103N

Program:…………………………………………………………
Section: …………………………………………………………….
Sem / Year: …………………………………………………………

Submitted By: Submitted To:

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
SESION: July-Dec 2022
BTCS103N Computer System Organization

Subject Name: Computer System Organization Code: BTCS103N

S. No. Name of Experiment Page No. Date Remark


1. Study of Peripherals, Components of
a Computer System.
2. Write a C program for sum of two
Binary numbers.
3. Write a C program for multiplication
of two Binary numbers.
4. Write a C program to implement
Booth’s Algorithm Multiplication.
5. Write a C program to implement
Restoring Division Algorithm.
6. Write the working of 8085 simulator
GNUsim8085 and basic architecture
of 8085 along with small introduction.
7. Study the complete instruction set of
8085 and write the instructions in the
instruction set of 8085 along with
example.
8. Write an assembly language code in
GNU8085 to implement data transfer
instruction.
9. Write an assembly language code in
GNU8085 to store number in reverse
order.
10. Write an assembly language code in
GNU8085 to add two 8-bit numbers
stored in memory and also storing the
carry.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 2
BTCS103N Computer System Organization

Experiment No.:1
1. Title: Study of Peripherals, Components of a Computer System.

2. Outcomes: Able to understand the role of the Peripherals of a Computer


System.

3. Objectives: To identify various Peripherals of a Computer System and know


their functioning in a Computer System Organization.

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

1. 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.

2. Types Of Common Peripheral Devices

Input Devices:

1. Keyboard
2. Computer mouse
3. Graphic tablet
4. Touchscreen
5. Barcode reader
6. Image scanner
7. Microphone
8. Webcam
9. Game controller
10. Light pen
11. Scanner
12. Digital camera

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 3
BTCS103N Computer System Organization
Output Devices:
1. Speaker
2. Monitor
3. Printer
4. Headphone
5. Projector

Storage Devices:

1. Pen Drive

2. Hard Drive
3. USB
4. DVD
5. Floppy Disk
6. 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

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 4
BTCS103N Computer System Organization
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)

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 5
BTCS103N Computer System Organization
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

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 6
BTCS103N Computer System Organization
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 another 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 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 copy because 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.

➢ Speakers
➢ Headphones
➢ Screen (Monitor)
➢ Printer
➢ Automotive navigation system
➢ Projector

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 7
BTCS103N Computer System Organization
➢ 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:

Volatile memory is computer memory that requires power to maintain the stored information.
Most modern semiconductor 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:

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.

Viva Questions:

1. What are the types of the computers?


2. What are the functional units of a computers?
3. What is program?
4. What is object program?
5. What do you mean by bit, byte, nibble and word?

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 8
BTCS103N Computer System Organization
6. Define RAM.
7. Define word length.
8. Define memory access time.
9. What is primary and secondary storage?
10. What are the registers?

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 9
BTCS103N Computer System Organization

Experiment No.:2
1. Title: Write a C program for sum of two Binary numbers.

2. Outcomes: To understand the concept of binary addition.

3. Objectives: To be able to write a program for addition of binary numbers.

4. Theory:

How do you sum two binary numbers?

The binary addition operation works similarly to the base 10 decimal system, except that it is a
base 2 system. The binary system consists of only two digits, 1 and 0.
The four rules of binary addition are:

1. 0 + 0 = 0.

2. 0 + 1 = 1.

3. 1 + 0 = 1.

4. 1 + 1 =10.

Problem Description:

This program finds the sum of two binary numbers.

Problem Solution:

1. Take two binary numbers as input.


2. Add each bit from the two binary numbers separately starting from LSB.
3. The operations may be as follows.
a) (0+0)=0,
b) (1+0)=1,
c) (1+1)=0 and 1 will be remainder.

Program/Source Code

Here is source code of the C program to Find the Sum of two Binary Numbers. The C program
is successfully compiled and run on a Linux system. The program output is also shown below.

Code:

#include <stdio.h>

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 10
BTCS103N Computer System Organization

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;
}

Program Explanation:

1. Take two binary numbers as input and store it in the variables binary1 and binary2.
2. Initialize the variables i and remainder to zero.
3. Obtain the remainders of both the binary numbers.
4. Obtain the quotients of both the binary numbers.
5. Firstly, add the remainders of both binary numbers and further add the variable remainder.
6. Obtain the remainder of the result got at step 5 when divided by 2 and store it in the array

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 11
BTCS103N Computer System Organization
sum[].
7. Obtain the quotient of the result got at step 5 when divided by 2 and override the variable
remainder with this value.
8. Override the variables binary1 and binary2 with their quotient got at step 4.
9. Repeat the steps 3-8 with the new values of binary1 and binary2 until both becomes zero.
10. When it becomes zero check if any remainder exits. If it is, then copy it into the array sum.
11. Print the sum as output.

Output:

Output:

Enter the first binary number: 100000

Enter the second binary number: 101010

Sum of two binary numbers: 1001010

Viva Questions:

1. What is the use of modulo operator?


2. Write data types in C.
3. What is an array?
4. Write the role of while loop.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 12
BTCS103N Computer System Organization

Experiment No.:3
1. Title: Write a C program for multiplication of two Binary numbers.

2. Outcomes: To understand the concept of binary multiplication.

3. Objectives: To be able to write a program for multiplication of binary


numbers.

4. Theory:

This is a C program to Calculate Multiplication of two Binary Numbers.

Problem Description:

This program takes two binary numbers as input and multiply them.

Problem Solution:

1.Take two binary numbers as input.


2. Do the repeated addition of binary numbers.
3. The result is the output.

Program/Source Code:

Here is source code of the C program to Calculate Multiplication of two Binary Numbers.The
C program is successfully compiled and run on a Linux system. The program output is also
shown below.

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: ");

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 13
BTCS103N Computer System Organization

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)

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 14
BTCS103N Computer System Organization

sum[i++] = remainder;
--i;
while (i >= 0)
binaryprod = binaryprod * 10 + sum[i--];
return binaryprod;
}

Program Explanation:

1. Take two binary numbers as input and store it in the variables binary1 and binary.
2. Initialize the variables multiply and factor with 0 and 1 respectively.
3. Divide the variable binary2 by 10 and obtain its remainder. Store this remainder in the
variable digit.
4. Check if the digit is equal to 1 or 0. If it is 1, then multiply binary 1 with factor and
override binary1 with this value. Call function binary product () by passing binary1 and
multiply as parameters.
5. If it is 0, then multiply binary 1 with factor and override binary1 with this value and
override binary2 with its quotient got when it is divided by 10.
6. Do steps 2-4 until binary2 becomes zero.
7. In the function binaryproduct(), obtain the remainder and quotient of both the
parameters.
8. Firstly, add the remainders of both parameters and further add the variable remainder.
9. Obtain the remainder and quotient of the result got at step 7 when divided by 2. Store the
remainder in the array sum[] and override the variable remainder with the quotient.
10. Override the variables binary1 and binary2 with their quotient got at step 6.
11. Repeat the steps 6-9 with the new values of binary1 and binary2 until both becomes zero.
12. When it becomes zero check if any remainder exits. If it is, then copy it into the array
sum.
13. Multiply the variable binaryprod with 10 and add the result to array sum. Override the
variable binaryprod with the got result. Do this step for all array elements and return
binaryprod.
14. Print the output and exit.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 15
BTCS103N Computer System Organization
Output:

Output:
Enter the first binary number: 10010
Enter the second binary number: 10101
Product of two binary numbers: 101111010

Viva Questions:

1. What is a function in C Program? Write types of functions?


2. Write a C code to implement conversion of decimal number to binary number.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 16
BTCS103N Computer System Organization

Experiment No.:4
1. Title: Write a C program to implement Booth’s Algorithm Multiplication.

2. Outcomes: To understand the concept of Booth’s Algorithm for


multiplication of two binary numbers.

3. Objectives: To be able to write a program for multiplication of binary


numbers using Booth’s Algorithm.

4. Theory:

Booth algorithm gives a procedure for multiplying binary integers in signed 2’s complement
representation in efficient way, i.e., less number of additions/subtractions required. It operates
on the fact that strings of 0’s in the multiplier require no addition but just shifting and a string
of 1’s in the multiplier from bit weight 2^k to weight 2^m can be treated as 2^(k+1 ) to 2^m.
As in all multiplication schemes, booth algorithm requires examination of the multiplier
bits and shifting of the partial product. Prior to the shifting, the multiplicand may be added to
the partial product, subtracted from the partial product, or left unchanged according to
following rules:

1. The multiplicand is subtracted from the partial product upon encountering the first
least significant 1 in a string of 1’s in the multiplier

2. The multiplicand is added to the partial product upon encountering the first 0
(provided that there was a previous ‘1’) in a string of 0’s in the multiplier.

3. The partial product does not change when the multiplier bit is identical to the
previous multiplier bit.

Hardware Implementation of Booths Algorithm: The hardware implementation of the


booth algorithm requires the register configuration shown in the figure below.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 17
BTCS103N Computer System Organization

Booth's Multiplication Algorithm:


The booth algorithm is a multiplication algorithm that allows us to multiply the two signed
binary integers in 2's complement, respectively. It is also used to speed up the performance of
the multiplication process. It is very efficient too. It works on the string bits 0's in the multiplier
that requires no additional bit only shift the right-most string bits and a string of 1's in a multiplier
bit weight 2k to weight 2m that can be considered as 2k+ 1 - 2m.

Following is the pictorial representation of the Booth's Algorithm:

In the above flowchart, initially, AC and Qn + 1 bits are set to 0, and the SC is a sequence counter
that represents the total bits set n, which is equal to the number of bits in the multiplier. There
are BR that represent the multiplicand bits, and QR represents the multiplier bits. After that,
we encountered two bits of the multiplier as Qn and Qn + 1, where Qn represents the last bit of
QR, and Qn + 1 represents the incremented bit of Qn by 1. Suppose two bits of the multiplier is
Shri Vaishnav Institute of Information Technology
Department of Computer Science & Engineering
Page | 18
BTCS103N Computer System Organization
equal to 10; it means that we have to subtract the multiplier from the partial product in the
accumulator AC and then perform the arithmetic shift operation (ashr). If the two of the
multipliers equal to 01, it means we need to perform the addition of the multiplicand to the
partial product in accumulator AC and then perform the arithmetic shift operation (ashr),
including Qn + 1. The arithmetic shift operation is used in Booth's algorithm to shift AC and QR
bits to the right by one and remains the sign bit in AC unchanged. And the sequence counter is
continuously decremented till the computational loop is repeated, equal to the number of bits
(n).

Working on the Booth Algorithm:

1. Set the Multiplicand and Multiplier binary bits as M and Q, respectively.

2. Initially, we set the AC and Qn + 1 registers value to 0.

3. SC represents the number of Multiplier bits (Q), and it is a sequence counter that is
continuously decremented till equal to the number of bits (n) or reached to 0.

4. A Qn represents the last bit of the Q, and the Qn+1 shows the incremented bit of Qn by 1.

5. On each cycle of the booth algorithm, Qn and Qn + 1 bits will be checked on the following
parameters as follows:

i. When two bits Qn and Qn + 1 are 00 or 11, we simply perform the arithmetic shift
right operation (ashr) to the partial product AC. And the bits of Qn and Qn + 1 is
incremented by 1 bit.

ii. If the bits of Qn and Qn + 1 is shows to 01, the multiplicand bits (M) will be added
to the AC (Accumulator register). After that, we perform the right shift operation
to the AC and QR bits by 1.

iii. If the bits of Qn and Qn + 1 is shows to 10, the multiplicand bits (M) will be
subtracted from the AC (Accumulator register). After that, we perform the right
shift operation to the AC and QR bits by 1.

6. The operation continuously works till we reached n - 1 bit in the booth algorithm.

7. Results of the Multiplication binary bits will be stored in the AC and QR registers.

This is a C Program to multiply two signed numbers using booth’s algorithm. Booth’s
multiplication algorithm is a multiplication algorithm that multiplies two signed binary numbers
in two’s complement notation. Booth used desk calculators that were faster at shifting than

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 19
BTCS103N Computer System Organization
adding and created the algorithm to increase their speed. Booth’s algorithm is of interest in the
study of computer architecture.

Here is the source code of the C program to multiply two signed numbers using booth’s
algorithm. The C program is successfully compiled and run on a Linux system. The program
output is also shown below.

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;

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 20
BTCS103N Computer System Organization

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--)

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 21
BTCS103N Computer System Organization

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--)

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 22
BTCS103N Computer System Organization

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)

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 23
BTCS103N Computer System Organization

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];

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 24
BTCS103N Computer System Organization

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\t BOOTH'S MULTIPLICATION ALGORITHM");

printf("\n Enter two numbers to multiply: ");

printf("\n Both must be less than 16");

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 25
BTCS103N Computer System Organization

//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 = ");

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 26
BTCS103N Computer System Organization

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);

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 27
BTCS103N Computer System Organization

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:

BOOTHS MULTIPLICATION ALGORITHM

Enter two numbers to multiply: 12 12

Both must be less than 16

Enter A: Enter B:

Expected product = 144

Binary Equivalents are:

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 28
BTCS103N Computer System Organization

A = 01100

B = 01100

B'' + 1 = 10100

-->

AR-SHIFT: 00000:00110

-->

AR-SHIFT: 00000:00011

-->

SUB B: 10100:00011

AR-SHIFT: 11010:00001

-->

AR-SHIFT: 11101:00000

-->

ADD B: 01001:00000

AR-SHIFT: 00100:10000

Product is = 0010010000

Viva Questions:
1. Write the concept of Booth’s Algorithm.
2. Write a C code to shift binary numbers by 2 bits.
3. Write a C code to implement 1’s complement of a binary number.
4. Write a C code to implement 2’s complement of a binary number.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 29
BTCS103N Computer System Organization

Experiment No.:5
1.Title: Write a C program to implement Restoring Division Algorithm.

2. Outcomes: To understand the concept of Restoring Division Algorithm.

3. Objectives: To be able to write a program to implement Restoring Division


Algorithm.

4. Theory: Restoring Division Algorithm for Unsigned Integer:

Restoring division is usually performed on the fixed-point fractional numbers. When we perform
division operations on two numbers, the division algorithm will give us two things, i.e., quotient
and remainder. This algorithm is based on the assumption that 0 < D < N. With the help of digit
set {0, 1}, the quotient digit q will be formed in the restoring division algorithm. The division
algorithm is generally of two types, i.e., fast algorithm and slow algorithm. Goldschmidt and
Newton-Raphson are the types of fast division algorithm, and STR algorithm, restoring
algorithm, non-performing algorithm, and the non-restoring algorithm are the types of slow
division algorithm.

In this section, we are going to perform restoring algorithm with the help of an unsigned integer.
We are using restoring term because we know that the value of register A will be restored after
each iteration. We will also try to solve this problem using the flow chart and apply bit
operations.

Here, register Q is used to contain the quotient, and register A is used to contain the remainder.
Here, the divisor will be loaded into the register M, and n-bit divided will be loaded into the

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 30
BTCS103N Computer System Organization
register Q. 0 is the starting value of a register. The values of these types of registers are restored
at the time of iteration. That's why it is known as restoring.

Now we will learn some steps of restoring division algorithm, which is described as follows:

Step 1: In this step, the corresponding value will be initialized to the registers, i.e., register A
will contain value 0, register M will contain Divisor, register Q will contain Dividend, and N is
used to specify the number of bits in dividend.

Step 2: In this step, register A and register Q will be treated as a single unit, and the value of
both the registers will be shifted left.

Step 3: After that, the value of register M will be subtracted from register A. The result of
subtraction will be stored in register A.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 31
BTCS103N Computer System Organization
Step 4: Now, check the most significant bit of register A. If this bit of register A is 0, then the
least significant bit of register Q will be set with a value 1. If the most significant bit of A is 1,
then the least significant bit of register Q will be set to with value 0, and restore the value of A
that means it will restore the value of register A before subtraction with M.

Step 5: After that, the value of N will be decremented. Here n is used as a counter.

Step 6: Now, if the value of N is 0, we will break the loop. Otherwise, we have to again go to
step 2.

Step 7: This is the last step. In this step, the quotient is contained in the register Q, and the
remainder is contained in register A.

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)

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 32
BTCS103N Computer System Organization

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++)

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 33
BTCS103N Computer System Organization

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;

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 34
BTCS103N Computer System Organization

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

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 35
BTCS103N Computer System Organization

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;

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 36
BTCS103N Computer System Organization

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;

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 37
BTCS103N Computer System Organization
Output:

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 38
BTCS103N Computer System Organization

Experiment No.:6
1. Title: Write the working of 8085 simulator GNUsim8085 and basic
architecture of 8085 along with small introduction.

2. Outcomes: To know the working of 8085 simulator GNUsim8085 and


understand its basic architecture.

3. Objectives: To identify various elements in the architecture of 8085 and


understand its operation.

4. Theory: 8085 Architecture:

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 39
BTCS103N Computer System Organization
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.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 40
BTCS103N Computer System Organization
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 –

The flag register of 8085 contains the five flip-flops, which are used as flags or status signals of
arithmetic or logical operation. On execution of certain instructions, the flags change its status.
A particular flag is set by forcing the flip-flop (1- bit register) to ‘1’ and is reset by forcing the
bit to ‘0’. The five status flags of 8085 are briefly explained as follows:

1. Sign Flag: If the most significant bit of the result of an operation is zero or nonzero. It is
set if the result is zero, otherwise it is reset.
2. Zero Flag: It indicates whether the result of an operation is zero or non-zero. It is set if
the result is zero, otherwise it is reset.
3. Parity Flag: It indicates the parity of the result. If the parity is even then it is set, otherwise
it is reset.
4. Carry Flag: It indicates a carry out of the most significant bit of the result. If the

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 41
BTCS103N Computer System Organization
instruction results in a carry (from addition) or borrow (from subtraction) out of the
MSB,this flag is set, otherwise it is reset.
5. Auxiliary Carry Flag: It holds the carry between the least significant and the most
significant nibbles of the result. If there is a carry from 4th bit to the 5th bit, i.e. from
lower nibble to the higher nibble, AC is set, otherwise it is reset.

6. The program counter: The program counter keeps the track of the address of the
memory location containing the next instruction to be executed in the program memory.
This is a 16-bit register. Another 16- bit special purpose register is a stack pointer, which
keeps a track of the stack, and holds the address of the top of the stack.

Instruction registers 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 microprocessors: 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).

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 42
BTCS103N Computer System Organization
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.

Programming Model of the 8085:

The programming model of the 8085 is shown in the figure 1. 8085 contains ten registers (eight
registers of 8-bits and two registers of 16-bit) which can be used by the programmer. Some of
these registers are general-purpose registers which can be used by the programmer in any
manner, whereas others are special purpose registers used for some specific purposes.

Figure1: Register Set of 8085

The registers B, C, D, E, H, L are 8-bit general purpose registers which can be used either
individually as 8-bit registers or as 16-bit register pair BC, DE, HL. These register pairs are used
to hold addresses or 16-bit data by some of the instructions The register pair HL can be used
either as a pointer to a memory location or it acts as a accumulator for double byte addition. The

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 43
BTCS103N Computer System Organization
register pairs BC and DE can also be used as pointers but by a very limited number of
instructions.

The accumulator and the flag registers are amongst the 8-bit special purpose registers and asa
one word known as Processor Status Word (PSW). The accumulator also known as register A
is an 8-bit special purpose register. In almost every arithmetic and logical
operation/Instructions, one of the operands (on which the operation is to be performed) is taken
from accumulator and the result is also placed in the accumulator.

The other operand can either be in the memory or any other register. All the data transfers
between CPU and I/O also take place through this accumulator (A).

Simulating Your Intel Processor with GNUSim8085:

For engineers looking to program their processors as per specific applications, a good number
of open-source simulation tools are available. GNUSim8085 is one such software. This cross-
platform software enables users to digitally simulate, assemble and debug the Intel 8085 8-bit
microprocessor—a power-efficient component for applications like security controls and
automatic controls.

The Intel 8085 processor is comparatively difficult to code directly due to the lack of an
integrated editor or compiler and limited debugging capacity. GNUSim8085 simulator tool eases
these difficulties by digitally designing and debugging the code to learn the processor’s
behaviour before encoding the actual hardware.

Features of GNUSim8085:

Digital representation of Intel 8085 by the software gives you a clear depiction of registers, ports
and memory. The simulation has input and output mechanism identical to the actual hardware’s.
The biggest advantage of this software is the introduction of an assembler and an editor for the
8085 processor. The editor comes with syntax highlighting. The software can display the
processor’s registers and flags. Along with these, the user can also view input/output (I/O) ports,
memory and stack contents. The hexadecimal-to-decimal converter adds a major advantage.The
GNUSim8085 software supports different languages and is print-capable. It is compatible with
Linux and Windows operating systems.

Using the software: The software launches a workspace with sample codes that can be worked
on. A toolbar on the top contains various options including File, Reset, Assembler, Debug and
Help. Users can open a new project from File->New. The user interface (UI) is very
comprehensive and user-friendly.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 44
BTCS103N Computer System Organization

The left panel contains a compact overview of the Intel processor’s registers and flags. The
hexadecimal-to-decimal converter is located in this panel as well. The value to be converted
needs to be inserted manually. Below the converter, two spinboxes are available. One is for the
I/O port value and the other for the memory port value. Entering the port number in the numeric
box displays the port content in the adjacent text box. The default entry format is decimal. You
can enter hex formats as well by adding an ‘h’ before the number. Users can update port values
from these spinboxes.

The right panel comes with multiple tabs that list values of the processor’s different entities. The
first tab is ‘Data,’ which enlists the defined data variables. The following tab is ‘Stack,’ which
displays addresses and values of entire stacks in the program. Stack values are updated when
you initialise a stack pointer and execute a stack function like Push or Call. Two other tabs
include I/O port and memory port, which enlist values and contents of I/O ports and memory
ports, respectively. An additional tab opens a virtual keypad, which allows users to digitally
insert values.

At the lower end of the right panel is a message box that displays messages related to program
compilation and execution. In case of any error, the message box displays an error message
mentioning the location and reason of error. Successful program execution displays a success
message.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 45
BTCS103N Computer System Organization
Assembler:

Assembler is an option in the other top toolbox that opens various functionalities of the tool’s
assembly unit. Its main function is to convert the code written in mnemonics to 8085-compatible
machine code. Major elements of Assembler include Mnemonics, which are instruction strings
of operations; Labels, which are targeted named points in the code for Call commands;
Comments, which are not part of the code but are remarks for the coder’s convenience; and
Pseudo-opcodes.

Fig. 2: The Assembler listing of GNUSim


There are three sub-menus in the Assembler menu. The first is Assemble, which loads the
program code to the memory address. The second is Execute, which compiles and runs the
loaded program. The third option is Show Listing, where users can view the executed program
code along with the relevant memory address opcode, mnemonics and comments. The main
importance of this option lies in preparing the program for moving into the actual hardware by
either saving as a file and printing or viewing the complete listing.

Debug and reset:

The simulator toolbar has two other menus. One is Debug. It consists of sub-menus Step In, Step
Over and Step Out. These make code debugging easy by analysing the register and memory
content in each step. Debug menu also comes with a code breakpoint feature.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 46
BTCS103N Computer System Organization
Reset menu can help users to erase old data from the simulator and reset values of registers,
ports, flags and memory. Reset can be done individually for each component or for all at once.

Viva Questions:

1. What is simulator?

2. Write register set of 8085 microprocessors.

3. What is a flag register?

4. What is assembler and debugger?

5. Write the features of 8085 Simulator.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 47
BTCS103N Computer System Organization

Experiment No.:7
1.Title: Study the complete instruction set of 8085 and write the instructions
in the instruction set of 8085 along with example.

2. Outcomes: To be able to understand the instruction set of 8085.

3. Objectives: To identify the instruction set of 8085 microprocessor and


write instructions out of the instruction set of 8085.

4. Theory: Instruction and Data Format:

The memory used in 8085-microprocessor system is organized in 8-bits. Each byte has a unique
location in the physical memory. The location is described by one of a sequence of 16-bit binary
addresses. Data in the 8085 is stored in form of 8-bit binary integers.

There are three different instruction formats namely.

▪ One-byte Instructions

▪ Two-byte instructions
▪ Three-byte instructions
All these formats have been shown in the figure 2. The first byte of all the instructions is the
OPCODE (operation code), which tells the CPU about the operation to be performed and to be
used by the instruction. The multi byte instructions must be stored in the successive memory
locations in which the address of the first byte is taken as the address of the instruction.

▪ One-byte instructions: - Such instructions contain only the opcode part. Most of the
instructions of 8085 are one-byte instructions.

▪ Two-byte instructions: - Such instructions contain the opcode in the first byte and an
8-bit operand in the next byte. The operand can be an 8-bit data or an I/O address.

▪ Three- b y t e instructions: - Such instructions have opcode in the first byte and 16-
bitoperand is contained in the following second and third byte of the instructions.

The operand can be a 16-bit data or a memory address. The second byte contains the least
significant or lower order byte, and the third byte contains the most significant or higher order
byte of the two-byte data or address. For example, if the 16-bit data is 4312 H, it is coded in the
instructions as 12, 34 in the second and third bytes respectively.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 48
BTCS103N Computer System Organization

Formats of the 1-byte, 2-byte and 3-byte instructions

Addressing Modes Of 8085:

Each instruction specifies an operation to be performed on certain data called operands. These
operands may be a part of the instruction, reside in one of the internal registers, stored in a
memory or held in the I/O. The various techniques used by the CPU, by which the address of
the data to be operated upon are specified, are called its addressing modes. In 8085 and many
other microprocessors the following five addressing modes are used: -

▪ Direct Addressing

▪ Register Addressing

▪ Register Indirect Addressing

▪ Immediate Addressing

▪ Implicit Addressing

Direct Addressing:

In this mode the actual address of the operand is in the memory and is explicitly specified with
the instruction itself. A 16-bit memory address follows the opcode of the instructionand
hence all such instructions are three bytes long.

For Example –

LDA 1234H (Load the accumulator directly from memory Location 1234H)

STA 2345H (Store the contents of the accumulator direct into memory location 2345H)

Register Addressing:

In this mode the operand for any operation is in any of the general-purpose registers. These can
be the registers B, C, D, E, H, L or A or even the register pairs BC, DE, HL or SP. These are
only one-byte instructions and within that byte, along with the operation code, theregister(s) is

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 49
BTCS103N Computer System Organization
(are) also specified. For example, the MOV and ADD instructions permit register addressing.
For Example -

MOV A, B // (Move the contents of the reg. B to


reg. A)ADD C // (Add the contents of reg. C to reg. A)
MOV E, A // (Move the contents of reg. A to reg E)

Register Indirect Addressing:

In this mode of addressing, a specified register pair holds the address of the actual memory
location containing the operand. The content of the memory location whose address is stored in
HL register pair is the actual operand. The register pair HL is a special register pair used for
indirect register addressing. It is defined as register M.

Consider the instruction MOV A, M. It is one byte instruction. Assume that at the time of
execution, the register pair HL contains 2345 H. So, due to this instruction, the contents of
memory location 2345 H will be transferred to the accumulator.

Immediate Addressing:

In this mode of addressing, the operand is specified within the instruction itself. The operand or
data is placed immediate after the opcode. This data can be 8-bit or 16-bit and depending on the
data the instruction is of two byte or one byte long.

For Example -

MVI A, 40H is an immediate addressing instruction. The mnemonic MVI stands for ‘move
immediate’. As the data following the op-code is of single byte; this is a two byte instruction.
On execution of this instruction the data 40H shall be transferred to the accumulator. The other
examples of the immediate addressing are ADI, LXI etc.

Implicit Addressing:

There are certain instructions in the instruction set of the 8085 that operate only on one operand.
Such instructions assume that the operand is in the implied register and usually it is in the
accumulator. Many instructions in the logical group like RLC, RRC, CMA falls into this
category. All these instructions are one-byte instructions.

Classification of Instructions:

Introduction: - The instruction set of the 8085 has been directly divided into five major
categories-

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 50
BTCS103N Computer System Organization
▪ Data transfer or copy instruction

▪ Arithmetic Instructions

▪ Logical Instructions

▪ Branching Instructions

▪ Stack, I/O and Machine control operations

Copy Instructions also called Data Transfer Instructions:

This group of instructions copies data from a location called a source to another location called
a destination, without modifying the contents of the source. In technical manuals, the term data
transfer is used for this copying function, However the use of term Data transfer is misleading
since it creates an impression that contents of the source are transferred (moved) while they are
only copied. This operation is mainly performed between (a) Registers, (b) between Specific
data byte and the register, (c) between a memory location and the register, (d) between an I/O
device and the accumulator. One of the primary functions of the microprocessor is copying
data, from a register called the source, to another register called the destination. In technical
literature, the copying function is frequently labeled as the data transfer function. In fact the
contents of the source are not transferred but are copied into the destination register without
modifying the contents of the source. Several instructions are used for this purpose. The main,
among them is:

OPCODE OPERAND DESCRIPTION

MOV
Rd, Rs Move
MVI R, 8-bit data Move Immediate
OUT 8-bit port address Output to port
IN 8-bit port address Input from port
HLT Halt
NOP No operation
LXI Rp, 16-bit address Load register pair immediate
MOV R, M Move (memory to register)
LDAX B/D Load accumulator indirect
LDA 16-bit address Load accumulator direct
MOV M, R Move (register to memory)
STAX B/D Store accumulator indirect

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 51
BTCS103N Computer System Organization

STA 16-bit address Store accumulator direct


MVI M, 8-bit data Load 8-bit data in memory

After knowing the various instructions in the data transfer group we now use the Dynalog-85
kit to perform couple of the sample programs before we proceed to solve the unknown
problems.

Sample Programs:

Following two sample programs of the data transfer instructions are given. You should go
through these sample programs for hands on practice. Moreover we find out the machine codes
from the chart of the hex codes and execute the program.

Load the hexadecimal number 37H in the register B, 40H in the register C, 42H in the register D, 32H
in the register E and store the contents of the registers B, C, D, and E to the memory locations 2050H,
2051H, 2052H and 2053H.

Solution:

The steps involved in solving the above problem are -

Step-1: Load register B, with the number 37H

Step-2: Load the register C, with the number 40 H

Step-3: Load the register D, with number 42 H

Step-4: Load the register E, with the number 32 H.

Step-5: Transfer the contents of the register B, to register A.

Step-6: Store the contents of the accumulator into the memory location XX50H

Step-7: Transfer the contents of the register C into the accumulator A

Step-8: Store the contents of the accumulator into the memory location XX51H

Step-9: Transfer the contents of the register D, into the register A.

Step-10: Store the contents of the accumulator into the memory location XX52H

Step-11: Transfer the contents of the register E, to the register A.

Step-12: Store the contents of the accumulator into the memory location XX53H

Step-13: Halt.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 52
BTCS103N Computer System Organization
Hence, the program will be:

Memory address Label Mnemonics and operands

E000H MVI B, 37H


E002H MVI C, 40H
E004H MVI D, 42H
E006H MVI E, 32H
E008H MOV A, B
E009H STA 2050H
E00CH MOV A, C
E00DH STA 2051H
E010H MOV A, D
E011H STA 2052H
E014H MOV A, E
E015H STA 2053H
E018H HLT

Result:

The mnemonics for the above program has been given and you are required to find out the hex
codes for the above program and load those codes in the Dynalog –85 kit. After execution of
the program the memory locations 2050 to 2053 should contain 37H, 40H, 42H & 32H
respectively.

Sixteen bytes of data are stored in the memory locations at E050H to E05FH. Transferthe entire block
of data to a new memory location starting from E070H The sixteen bytes of data is (in Hex): - 37, A2,
F2, 57, 82, 5A, 7F, DA, E5, 8B, A7, C2, B8, 10, 19, 98.

Solution:
The steps involved in solving the above problem are -

Step-1: Set up HL as the pointer for the source memory.


Step-2: Set up DE as the pointer for the destination memory.
Step-3: Set up B as the byte counter.
Step-4: Get data byte from the source memory.
Step-5: Store the data byte from the source memory.
Step-6: Get ready to transfer next byte.
Step-7: Go back to get the next byte if byte counter is not equal to 0.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 53
BTCS103N Computer System Organization
Step-8: Otherwise, halt.

The program for the above problem -

Memory address Label Mnemonics & Operands

E000H Start: LXI H, E050H

E003H LXI D, E070H


E006H MVI B, 10H
E008H Next: MOV A, M
E009H STAX D
E00AH INX H
E00BH INX D
E00CH DCR B
E00DH JNZ Next
E010H HLT

Result:

After the execution of the program check the contents of the memory location starting from
E070H to ensure the block transfer. The above two programs are sufficient to give you the idea
of the data transfer function of the 8085 processor. You are now required to make coupleof
programs on your own and then execute them and get the results.

Viva Questions:

1. What happens in a single –board microcomputer when the power is turned on and thereset
key is pushed?
2. How does the microprocessor know how and when to start?
3. How does the microprocessor differentiate between a positive number and the negative
number?

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 54
BTCS103N Computer System Organization

Experiment No.:8
1.Title: Write an assembly language code in GNU8085 to implement data
transfer instruction.

2. Outcomes: To be able to understand the Assemble language code in 8085 to


implement data transfer instruction.

3. Objectives: To write data transfer instructions in 8085 and implement it in


program.

4. Theory: Copy Instructions also called Data Transfer Instructions:

This group of instructions copies data from a location called a source to another location called a
destination, without modifying the contents of the source. In technical manuals, the term data
transfer is used for this copying function, However the use of term Data transfer is misleading since
it creates an impression that contents of the source are transferred (moved) while they are only
copied. This operation is mainly performed between (a) Registers, (b) between Specific data byte
and the register, (c) between a memory location and the register, (d) between an I/O device and
the accumulator. One of the primary functions of the microprocessor is copying data, from a register
called the source, to another register called the destination. In technical literature, the copying
function is frequently labeled as the data transfer function. In fact the contents of the source are not
transferred but are copied into the destination register without modifying the contents of the source.
Several instructions are used for this purpose. The main, among them is:

OPCODE OPERAND DESCRIPTION

MOV Rd, Rs Move


MVI R, 8-bit data Move Immediate
OUT 8-bit port address Output to port
IN 8-bit port address Input from port
HLT Halt
NOP No operation
LXI Rp, 16-bit address Load register pair immediate
MOV R, M Move (memory to register)
LDAX B/D Load accumulator indirect
LDA 16-bit address Load accumulator direct
MOV M, R Move (register to memory)

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 55
BTCS103N Computer System Organization
STAX B/D Store accumulator indirect
STA 16-bit address Store accumulator direct
MVI M, 8-bit data Load 8-bit data in memory

After knowing the various instructions in the data transfer group, we now use the Dynalog-85 kit to
perform couple of the sample programs before we proceed to solve the unknown problems.

Sample Programs:

Following two sample programs of the data transfer instructions are given. You should go through
these sample programs for hands on practice. Moreover, we find out the machine codes from the
chart of the hex codes and execute the program.

Load the hexadecimal number 37H in the register B, 40H in the register C, 42H in the register D,
32H in the register E and store the contents of the registers B, C, D, and E to the memory locations
2050H, 2051H, 2052H and 2053H.

Solution:

The steps involved in solving the above problem are -


Step-1: Load register B, with the number 37H
Step-2: Load the register C, with the number 40 H
Step-3: Load the register D, with number 42 H
Step-4: Load the register E, with the number 32 H.
Step-5: Transfer the contents of the register B, to register A.
Step-6: Store the contents of the accumulator into the memory location XX50H
Step-7: Transfer the contents of the register C into the accumulator A
Step-8: Store the contents of the accumulator into the memory location XX51H
Step-9: Transfer the contents of the register D, into the register A.
Step-10: Store the contents of the accumulator into the memory location XX52H
Step-11: Transfer the contents of the register E, to the register A.
Step-12: Store the contents of the accumulator into the memory location XX53H
Step-13: Halt.
Hence, the program will be -
Memory address Label Mnemonics and operands

E000H MVI B, 37H


E002H MVI C, 40H
E004H MVI D, 42H

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 56
BTCS103N Computer System Organization

E006H MVI E, 32H


E008H MOV A, B
E009H STA 2050H
E00CH MOV A, C
E00DH STA 2051H
E010H MOV A, D
E011H STA 2052H
E014H MOV A, E
E015H STA 2053H
E018H HLT
Result:

The mnemonics for the above program has been given and you are required to find out the hex
codes for the above program and load those codes in the Dynalog –85 kit. After execution of the
program the memory locations 2050 to 2053 should contain 37H, 40H, 42H & 32H respectively.

Code:

LDA 0000

MOV B, A

LDA 0001

HLT

Output:

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 57
BTCS103N Computer System Organization
Viva Questions:

1. What is the function of following instructions: -


a. LDA
b. LXI
c. LDAX
d. STA
2. What is accumulator?
3. Which is the default register?
4. Write instructions to multiply and add two: -
a. 8-bit binary numbers.
b. 16-bit binary numbers.
5. What are data transfer instructions. What is the difference between move and copy
instructions.

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 58
BTCS103N Computer System Organization

Experiment No.:9
1.Title: Write an assembly language code in GNU8085 to store number in
reverse order.

2. Outcomes: To be able to write a program in 8085 to store number in reverse


order.

3. Objectives: To understand the concept of 8085 program to store number in


reverse order.

4. Theory: Logical Operations:

These instructions perform various logical operations with the contents of the accumulator such as
AND, OR, and EX-OR. In these operations the contents of the accumulator can be logically And,
Or, or Exclusive –Or gated with the contents of the register, or the memory location. The result will
be stored in the accumulator. The instructions such as ROTATE, COMPARE and COMPLEMENT
can also be executed. A microprocessor is basically a programmable logic chip. It can perform all
the logic functions of the hard-wired logic through instruction set. The 8085-instruction set includes
such logic functions as AND, OR, Ex-OR, and NOT (complement). The opcodes of these operations
are as follows -

OPCODE OPERAND DESCRIPTION

ANA R Logically AND with Accumulator


ANI 8-bit data AND Immediate with Accumulator.
ORA R Logically OR with Accumulator
ORI 8-bit data OR Immediate with Accumulator
XRA R Logically Exclusive-OR with accumulator
XRI 8-bit data Exclusive-OR Immediate with accumulator
CMA Complement the content of accumulator
RLC Rotate accumulator left
RAL Rotate accumulator left through carry
RRC Rotate accumulator right
RAR Rotate accumulator right through carry
CMP R/M Compare with accumulator

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 59
BTCS103N Computer System Organization
Sample Programs:

After going through the above instructions now the students are required to go through two sample
programs and find out the Hex codes for the sample programs and execute them onthe Dynalog-
85 kit.

• A set of ten current readings is stored in memory locations starting from E060 H. the
readings are expected to be positive. Write a program to -
• Check each reading to determine whether it is positive or negative.
• Reject all negative readings and add all positive readings.
• Store FF H in the memory location E070 H when the sum exceeds eight bits;otherwise,
store the sum.
• Data: 28, D8, C2, 21, 24, 30, 2F, 19, F2, 9F.

Solution:

The steps involved in solving the above problem are -

Step-01: Clear reg. B to save sum and set up reg. C as a counter.

Step-02: Set up HL as memory pair.

Step-03: Get byte into the accumulator.

Step-04: Shift D7 into carry, if D7 =1 reject byte and go to increment pointer

Step-05: If byte is positive restore it

Step-06: Add previous sum to accumulator, if sum is greater than FF H it is overload, Turnon
emergency.

Step-07: Save the sum and point to next reading and decrement the counter.

Step-08: If all readings are not checked than go back to the next byte.

Step-09: Store the sum in the memory E070 H.

Step-10: Store overload signal in the memory location E070 H.

Label Mnemonics
MVI B, 00H
MVI C, 0AH
LXI H, E060H

NEXT: MOV A, M
RAL
Shri Vaishnav Institute of Information Technology
Department of Computer Science & Engineering
Page | 60
BTCS103N Computer System Organization
JC: REJECT ADD B
JC: OVRLD
MOV B, A
REJECT: INX H
DCRC
JNZ: NEXT
STA E070H
OVRLD: MVI A, FFH
STA E070H
HLT

Code:
LDA 0002
RLC
RLC
RLC
RLC
STA 0003
HLT
Output:

Viva Questions:

1. What are various logical instructions?


2. Write difference between shift and rotate instructions?
Shri Vaishnav Institute of Information Technology
Department of Computer Science & Engineering
Page | 61
BTCS103N Computer System Organization

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

2. Outcomes: To be able to write an assembly code to add two 8-bit numbers with
carry.

3. Objectives: To understand the concept of assembly code in 8085 to add two 8-


bit numbers with carry stored in memory.

4. Theory:

Logical Operations:

These instructions perform various logical operations with the contents of the accumulator such as
AND, OR, and EX-OR. In these operations the contents of the accumulator can be logically And,
Or, or Exclusive –Or gated with the contents of the register, or the memory location. The result will
be stored in the accumulator. The instructions such as ROTATE, COMPARE and COMPLEMENT
can also be executed. A microprocessor is basically a programmable logic chip. It can perform all
the logic functions of the hard-wired logic through instruction set. The 8085-instruction set includes
such logic functions as AND, OR, Ex-OR, and NOT (complement). The opcodes of these operations
are as follows:

OPCODE OPERAND DESCRIPTION

ANA R Logically AND with Accumulator


ANI 8-bit data AND Immediate with Accumulator.
ORA R Logically OR with Accumulator
ORI 8-bit data OR Immediate with Accumulator
XRA R Logically Exclusive-OR with accumulator
XRI 8-bit data Exclusive-OR Immediate with accumulator
CMA Complement the content of accumulator
RLC Rotate accumulator left
RAL Rotate accumulator left through carry
RRC Rotate accumulator right
RAR Rotate accumulator right through carry
CMP R/M Compare with accumulator

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 62
BTCS103N Computer System Organization
Sample Programs:

A set of current readings is stored in the memory locations starting from E050 H. The end of the
data string is indicated by the data byte 00 H. Add the set of readings. The answer may be larger
than FF H. Store the answer in the memory locations E070 H and E071 H. Data: - 32, 52, F2, A5,
00.

Solution:

The steps involved in solving the above problem are -

Step-01: Setup HL as memory pointer, clear register C to save sum and clear register B to
save carry.
Step-02: Transfer current readings to the accumulator.
Step-03: Is this the last reading. If yes, go to display section.
Step-04: Otherwise add previous sum to accumulator.
Step-05: Skip carry registers if there is no carry otherwise update carry register and save the
sum.
Step-06: Point to the next reading and go back to the next reading.
Step-07: Otherwise, point index to E070 H location and store lower order on the E070 H, and
higher order in the E071 H.
Step-08: End of the program.
Label Mnemonics

START: LXI H, E050 H


MVI C, 00H
MOV B, C
NXTBYT: MOV A, M
CPI 00 H
JZ: DISP
ADD C
JNC: SAVEINR B
SAVE: MOV C, A
INX H
JMP: NXTBYT
DISP: LXI H, E070 H
MOV M, C

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 63
BTCS103N Computer System Organization
INX H
MOV M, B
HLT

Code:
LDA 0000
MOV B,A
LDA 0001
ADD B
STA 0002
HLT
Output:

Viva Questions:

1. Write instructions to add two 8-bit binary numbers:


a. With carry.
b. Without carry.
2. What is PSW? What is its use?
3. How is HL register pair denoted?

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | 64
BTCS103N Computer System Organization

Shri Vaishnav Institute of Information Technology


Department of Computer Science & Engineering
Page | a

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy