BTCS103N - Lab Manual
BTCS103N - Lab Manual
LAB MANUAL
COMPUTER SYSTEM ORGANIZATION
BTCS103N
Program:…………………………………………………………
Section: …………………………………………………………….
Sem / Year: …………………………………………………………
Experiment No.:1
1. Title: Study of Peripherals, Components of a Computer System.
4. Theory: A peripheral is a “device that is used to put information into or get information out of
the computer.
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.
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
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.
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
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)
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 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
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:
Experiment No.:2
1. Title: Write a C program for sum of two Binary numbers.
4. Theory:
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:
Problem Solution:
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>
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
Output:
Output:
Viva Questions:
Experiment No.:3
1. Title: Write a C program for multiplication of two Binary numbers.
4. Theory:
Problem Description:
This program takes two binary numbers as input and multiply them.
Problem Solution:
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>
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;
}
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.
Output:
Enter the first binary number: 10010
Enter the second binary number: 10101
Product of two binary numbers: 101111010
Viva Questions:
Experiment No.:4
1. Title: Write a C program to implement Booth’s Algorithm Multiplication.
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.
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).
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
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>
void binary()
a1 = fabs(a);
b1 = fabs(b);
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;
c = 0;
if(res[i] >= 2)
c = 1;
else
c = 0;
res[i] = res[i] % 2;
bcomp[i] = res[i];
if (a < 0)
c = 0;
res[i] = 0;
if (res[i] >= 2)
c = 1;
else
c = 0;
res[i] = res[i]%2;
anum[i] = res[i];
anumcp[i] = res[i];
temp = bnum[i];
bnum[i] = bcomp[i];
bcomp[i] = temp;
int i;
c = 0;
if (res[i] >= 2)
c = 1;
else{
c = 0;
res[i] = res[i]%2;
pro[i] = res[i];
printf("%d",pro[i]);
printf(":");
printf("%d", anumcp[i]);
void arshift()
pro[i-1] = pro[i];
pro[4] = temp;
anumcp[i-1] = anumcp[i];
anumcp[4] = temp2;
printf("%d",pro[i]);
printf(":");
printf("%d", anumcp[i]);
void main()
int i, q = 0;
Do
printf("\nEnter A: ");
scanf("%d",&a);
printf("Enter B: ");
scanf("%d", &b);
binary();
printf("\nA = ");
printf("%d", anum[i]);
printf("\nB = ");
printf("%d", bnum[i]);
printf("\nB'+ 1 = ");
printf("%d", bcomp[i]);
printf("\n\n");
printf("\n-->");
arshift();
q = anum[i];
printf("\n-->");
arshift();
q = anum[i];
printf("\n-->");
printf("\nADD B: ");
add(bnum);
arshift();
q = anum[i];
printf("\nProduct is = ");
printf("%d", pro[i]);
printf("%d", anumcp[i]);
Output:
Enter A: Enter B:
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.
Experiment No.:5
1.Title: Write a C program to implement Restoring Division Algorithm.
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
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.
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};
int q[100],b[100];
int main()
int x,y;
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;
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;
Experiment No.:6
1. Title: Write the working of 8085 simulator GNUsim8085 and basic
architecture of 8085 along with small introduction.
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.
As the name suggests, it performs arithmetic and logical operations like Addition, Subtraction,
AND, OR, etc. on 8-bit data.
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.
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.
● Sign (S)
● Zero (Z)
● Parity (P)
● Carry (C)
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
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.
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.
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 −
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.
It controls the serial data communication by using these two instructions: SID (Serial input data)
and SOD (Serial output data).
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.
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.
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.
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
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).
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.
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.
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.
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.
Viva Questions:
1. What is simulator?
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.
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.
▪ 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.
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
▪ 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
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-
▪ Arithmetic Instructions
▪ Logical Instructions
▪ Branching 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:
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
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:
Step-6: Store the contents of the accumulator into the memory location XX50H
Step-8: Store the contents of the accumulator into the memory location XX51H
Step-10: Store the contents of the accumulator into the memory location XX52H
Step-12: Store the contents of the accumulator into the memory location XX53H
Step-13: Halt.
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 -
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?
Experiment No.:8
1.Title: Write an assembly language code in GNU8085 to implement data
transfer instruction.
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:
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 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:
Experiment No.:9
1.Title: Write an assembly language code in GNU8085 to store number in
reverse order.
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 -
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:
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.
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:
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.
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:
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:
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
Code:
LDA 0000
MOV B,A
LDA 0001
ADD B
STA 0002
HLT
Output:
Viva Questions: