0% found this document useful (0 votes)
10 views39 pages

Mprocessor PDF

This document is a practical file detailing various experiments related to the 8085 microprocessor and GNUSim8085 Assembly Language simulator. It includes an introduction to the 8085 architecture, programming exercises for arithmetic operations, and the use of the GNUSim8085 simulator for assembly language coding. The file is structured with an index, aims, theories, and results for each experiment conducted.

Uploaded by

mashirnizami786
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)
10 views39 pages

Mprocessor PDF

This document is a practical file detailing various experiments related to the 8085 microprocessor and GNUSim8085 Assembly Language simulator. It includes an introduction to the 8085 architecture, programming exercises for arithmetic operations, and the use of the GNUSim8085 simulator for assembly language coding. The file is structured with an index, aims, theories, and results for each experiment conducted.

Uploaded by

mashirnizami786
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

MICROPROCESSOR AND MICROCONTROLLER PRACTICAL FILE

NAME MASHIR NIZAMI

ENROLLMENT NO. 01676802818

BRANCH ECE 3

Submitted to: Dr Gurmeet Singh

MASHIR NIZAMI (01676802818) 1|Page


INDEX

Sno. Topic Date Pg No


1 Introduction to 8085 microprocessor 07-10-20 3-11
2 Introduction to GNUSim8085 Assembly 14-10-20 12-18
Language simulator
3 Write a program for addition and 19-22
subtraction of two numbers without
carry using 8085 simulator
21-10-20

4 Write a program for addition and 23-26


subtraction of two 8-bit numbers with
carry using 8085 simulator.
28-10-20

5 Write a program for addition and 27-30


subtraction of two 16-bit numbers with
carry using 8085 simulator.
04-11-20

6 Write a program for multiplication and 31-34


division of two numbers using 8085
simulator.
11-11-20

7 Write a program for addition and 35-36


subtraction of two 8-bit numbers using
8086.
18-11-20

8 Write a program for multiplication of 25-11-20 37


two 16-bit numbers using 8086.

9 Write a program for division of two 16- 09-12-20 38


bit numbers using 8086.

10 Write a program for factorial of 16-bit 16-12-20 39


number using 8086

MASHIR NIZAMI (01676802818) 2|Page


EXPERIMENT-1

AIM :- Introduction to 8085 microprocessor.


Apparatus :- 8085 microprocessor.
Theory:
The 8085 microprocessor was made by Intel in mid 1970s. It was
binary compatible with 8080 microprocessor but required less
supporting hardware thus leading to less expensive microprocessor
systems. It is a general purpose microprocessor capable of addressing
64k of memory. The device has 40 pins, require a +5V power supply
and can operate with 3 MHz single phase clock.

8085 Internal Architecture Diagram

MASHIR NIZAMI (01676802818) 3|Page


8085 Internal Architecture
The 8085 has a 16 bit address bus which enables it to address 64 KB
of memory, a data bus 8 bit wide and control buses that carry
essential signals for various operations. It also has a built in register
array which are usually labelled A(Accumulator), B, C, D, E, H, and L.
Further special-purpose registers are the 16-bit Program Counter
(PC), Stack Pointer (SP), and 8-bit flag register F. The microprocessor
has three maskable interrupts (RST 7.5, RST 6.5 and RST 5.5), one
Non-Maskable interrupt (TRAP), and one externally serviced interrupt
(INTR).

Control Unit
It generates signals within microprocessor to carry out the
instruction, which has been decoded.

Arithmetic Logic Unit


The ALU performs the actual numerical and logic operation such as
„add‟, „subtract‟, „AND‟, „OR‟, etc. Uses data from memory and
from Accumulator to perform arithmetic and always stores the result
of operation in the Accumulator.

Registers
The 8085 microprocessor includes six registers, one accumulator, and
one flag [Link] has two 16-bit registers: the stack pointer and the

MASHIR NIZAMI (01676802818) 4|Page


program counter. The 8085 has six general-purpose registers to store
8-bit data; these are identified as B, C, D, E, H, and L
Accumulator
The accumulator is an 8-bit register that is a part of arithmetic/logic
unit (ALU). This register is used to store 8-bit data and to perform
arithmetic and logical operations. The result of an operation is stored
in the accumulator. The accumulator is also identified as register A.

Flag Registers
The ALU includes five flip-flops, which are set or reset after an
operation according to data conditions of the result in the
accumulator and other registers. They are called Zero(Z), Carry (CY),
Sign (S), Parity (P), and Auxiliary Carry (AC) flags. The most commonly
used flags are Zero, Carry, and Sign. The microprocessor uses these
flags to test data conditions.

Instruction Register / Decoder


This is a temporary storage for the current instruction of a program.
Latest instruction is sent to here from memory prior to execution.
Decoder then takes instruction and „decodes‟ or interprets the
instruction. Decoded instruction is then passed to next stage.

MASHIR NIZAMI (01676802818) 5|Page


Address Bus
The address bus is a group of 16 lines. The address bus is
unidirectional: bits flow only in one direction – from the 8085 to the
peripheral devices.

Data Bus
The data bus is a group of eight lines used for dataflow. They are
bidirectional: data flows in both direction between the 8085 and
memory and peripheral devices. The 8 lines enable the
microprocessor to manipulate 8-bit data ranging from 00 to FF.

Control Bus
The control bus consists of various single lines that carry
synchronization signals. The 8085 generates specific control signal for
each operation it performs. These signals are used to identify a device
type which the processor intends to communicate.

MASHIR NIZAMI (01676802818) 6|Page


8085 Pin Diagram:

A8-A15
Address Bus carries the most significant 8 bits of the memory address
or the 8 bits of the I/0 address.

AD0 - AD7
Multiplexed Address/Data Bus carries Lower 8 bits of the memory
address (or I/O address) appear on the bus during the first clock cycle
of a machine state.

MASHIR NIZAMI (01676802818) 7|Page


ALE (Output)
Address Latch Enable occurs during the first clock cycle of a machine
state and enables the address to get latched into the on chip latch of
peripherals.

RD
READ indicates the selected memory or 1/0 device is to be read and
that the Data Bus is available for the data transfer.

WR
WRITE indicates the data on the Data Bus is to be written into the
selected memory or 1/0 location.

READY (Input)
If Ready is high during a read or write cycle, it indicates that the
memory or peripheral is ready to send or receive data. If Ready is low,
the CPU will wait for Ready to go high before completing the read or
write cycle.

HOLD (Input)
HOLD indicates that another Master is requesting the use of the
address and data buses.

MASHIR NIZAMI (01676802818) 8|Page


HLDA (Output)
HOLD ACKNOWLEDGE indicates that the CPU has received the Hold
request and that it will relinquish the buses in the next clock cycle.
HLDA goes low after the Hold request is removed.

INTR (Input)
INTERRUPT REQUEST is used as a general purpose interrupt. It is
sampled only using the next to the last clock cycle of the instruction. If
it is active, the Program Counter (PC) will be inhibited from
incrementing and an INTA will be issued.

INTA (Output)
INTERRUPT ACKNOWLEDGE is used instead of (and has the same
timing as) RD during the Instruction cycle after an INTR is accepted.

RST 5.5/ RST 6.5/ RST 7.5


RESTART INTERRUPTS have the same timing as INTR except they
cause an internal RESTART to be automatically inserted.

TRAP (Input)
Trap interrupt is a non-maskable restart interrupt. It is recognized at
the same time as INTR. It is unaffected by any mask or Interrupt
Enable. It has the highest priority of any interrupt.

MASHIR NIZAMI (01676802818) 9|Page


RESET IN (Input)
Reset sets the Program Counter to zero and resets the Interrupt
Enable and HLDA flipflops. None of the other flags or registers (except
the instruction register) are affected.

RESET OUT (Output)


It indicates that CPU is been reset. It used as a system RESET. The
signal is synchronized to the processor clock.

X1, X2 (Input)
Crystal or R/C network connections to set the internal clock generator
X1 can also be an external clock input instead of a crystal.

CLK (Output)
Clock Output is used as a system clock when a crystal or R/ C network
is used as an input to the CPU. The period of CLK is twice the X1, X2
input period.

IO/M (Output)
IO/M indicates whether the Read/Write is to memory or l/O.

SID (Input)
Serial input data line:The data on this line is loaded into accumulator
bit 7 whenever a RIM instruction is executed.
MASHIR NIZAMI (01676802818) 10 |
Page
SOD (output)
Serial output data line: The output SOD is set or reset as specified by
the SIM instruction.

Vcc
+5V supply.

Vss
Ground Reference

Conclusion:
The 8085 Architecture has been studied

MASHIR NIZAMI (01676802818) 11 |


Page
EXPERIMENT-2

AIM: - Introduction to GNUSim8085 Assembly Language simulator


Apparatus: - 8085 microprocessor, GNUSim8085 Simulator
Theory:

GNUSim8085 is a graphical simulator, assembler and debugger for


the Intel 8085 microprocessor in Linux and Windows. GNUSim8085
users are encouraged to contribute to the simulator through coding,
documenting, testing, translating and porting the simulator.

Editor

1. Program editor with interactive input wizard for all the standard
instructions
2. Syntax highlighting in editor to distinguish between instructions,
operands, comments etc.
MASHIR NIZAMI (01676802818) 12 |
Page
3. A separate opcode view which displays assembled code in hex

Assembler

1. Support for all standard instructions of the 8085


2. Minimalistic support for three assembler directives (.equ, .db,
.ds) to control data locations, there exist no directives to
directly control code locations
3. Code start is defined outside source code ("load me at" entry) -
if not defined (default), code is generated (strangely) from
4200h (instead from the real reset vector 0000h)
4. Assembly results can be stored as listing file only (no binary file
output)

MASHIR NIZAMI (01676802818) 13 |


Page
Debugger

1. Complete view of registers and flags


2. Support for breakpoints
3. Step by step execution/debugging of program
4. Hex / Decimal Converter
5. Runtime inspection and manipulation of memory and I/O ports

Printing

1. Printing of program from editor as well as assembled hex code

MASHIR NIZAMI (01676802818) 14 |


Page
A basic assembly program consists of 4 parts.

a. Machine operations (mnemonics)


b. Pseudo operations (like pre-processor in C)
c. Labels
d. Comments

In addition, you have constants in an assembly program. Unless


otherwise specified, a constant which is always numberic is in decimal
form. If appended with a character ``h`` it is assumed to be in
hexadecimal form. If a hex constant starts with an alpha-char don't
forget to include the number ``0`` in the begining, since that will help
the assembler to differentiate between a label and a constant.

Labels
Labels when given to any particular instruction/data in a program,
takes the address of that instruction or data as its value. But it has
different meaning when given to ``EQU`` directive. Then it takes the
operand of ``EQU`` as its value. Labels must always be placed in the
first column and must be followed by an instruction (no empty line).
Labels must be followed by a ``:`` (colon), to differentiate it from
other tokens.

MASHIR NIZAMI (01676802818) 15 |


Page
Pseudo Ops

There are only 3 directives currently available in our assembly


language.

a. ``DB`` - define byte ( 8 bits )


b. ``DS`` - define size (no. of bytes)
c. ``EQU`` - like minimalistic ``#define`` in C

``DB`` is used to define space for an array of values specified by


comma seperated list. And the label (if given to the beginning of
``DB``) is assigned the address of the first data item. For example,
var1: db 34, 56h, 87

``EQU`` behaves similar to ``#define`` in C. But it is simple. It can be


used to give names only to numeric constants. Nesting of ``EQU`` is
not allowed.

Mnemonics
After all, I am using my spare time to do all these things. Writing a
BIG manual on 8085 instructions seems to be redundant and time
consuming
Comments start with a semi-colon (``;``). As you can see in the
previous example, comments can be given to any part of the
MASHIR NIZAMI (01676802818) 16 |
Page
program. Anything after ``;`` is ignored by the assembler, except to
one important character sequence

Auto breakpoints
As you get acquainted with the application, you can use breakpoints
to debug your program. But for certain programs, you have to display
something to the user before continuing
But for this program, every time you load it, you have to set the
breakpoints.

This can be automated. To set the breakpoint at line number `n`, you
have to put a special comment at line ``n-1``. And this comment
should start at first column. The sequence is :
 Don't forget to include the ``HLT`` instruction somewhere else in
the program to terminate it.
 Constant addresses should be used with caution. ``LDA 2200h``
will be ``3a 00 22`` in machine code . So the actual address is
again ``2200h``.
MASHIR NIZAMI (01676802818) 17 |
Page
Shortcut keys

Conclusion:
The 8085 GNU simulator has been studied

MASHIR NIZAMI (01676802818) 18 |


Page
EXPERIMENT-3

Aim: Write a program for addition and subtraction of two numbers


without carry using 8085 simulator

SOFTWARES USED: GNU SIMULATOR 8085

Theory:

1. MVI: This instruction will move the content of data from source
to destination
2. ADD B: This instruction will sum the content of the accumulator
with the content of the register B.
3. SUB B: This instruction will sub the content of the accumulator
with the content of the register B.
4. HLT: This instruction will terminate the program.

(a) Program: Program for addition two numbers without carry


SOURCE CODE:

MVI A, 10
MVI B, 05
ADD B
Hlt

MASHIR NIZAMI (01676802818) 19 |


Page
FLOW CHART:

SIMULATION RESULT

Result
0F is stored in accumulator and hence the additions of two numbers
have concluded.

MASHIR NIZAMI (01676802818) 20 |


Page
(b) Program: Program for subtraction two numbers without carry

SOURCE CODE:

MVI A, 12
MVI B, 04
SUB B
Hlt

FLOW CHART:

MASHIR NIZAMI (01676802818) 21 |


Page
SIMULATION RESULT

Result
08 is stored in accumulator and hence the subtraction of two
numbers have concluded.

MASHIR NIZAMI (01676802818) 22 |


Page
EXPERIMENT-4

Aim: Write a program for addition and subtraction of two 8-bit


numbers with carry using 8085 simulator.

SOFTWARES USED: GNU SIMULATOR 8085

Theory:

1. MVI: This instruction will move the content of data from source
to destination
2. ADD R adds contents of A (Accumulator) and R register .The
result is stored in A itself.
3. SUB R subtracts contents of A (Accumulator) and R register .The
result is stored in A itself.
4. HLT stops executing the program and halts any further
execution

(a) Program: Program for addition two numbers with carry


SOURCE CODE:

MVI A, 0A5H
MVI B, 66
ADD B
MVI C,00
ADC C
Hlt
MASHIR NIZAMI (01676802818) 23 |
Page
FLOW CHART:

SIMULATION RESULT

Result(a)
E7 is stored in accumulator and hence the additions of two numbers
have concluded.
MASHIR NIZAMI (01676802818) 24 |
Page
(b) Program: Program for subtraction two numbers with carry
SOURCE CODE:

MVI A, A5
MVI B, 66
SUB B
MVI D,00
SBB D
Hlt

FLOW CHART:

MASHIR NIZAMI (01676802818) 25 |


Page
SIMULATION RESULT

Result(b)
38 is stored in accumulator and hence the substraction of two
numbers have concluded.

MASHIR NIZAMI (01676802818) 26 |


Page
EXPERIMENT-5

Aim: Write a program for addition and subtraction of two 16-bit


numbers with carry using 8085 simulator.

SOFTWARES USED: GNU SIMULATOR 8085

Theory:

1. LHLD: this instruction loads the contents of the 16- bit


memory location into the HL register pair.
2. XCHG is an instruction to exchange contents of HL register pair
with DE register pair
3. DAD subtracts contents of A (Accumulator) and R register .The
result is stored in A itself.
4. SHLD Store HL register pair’s content to memory locations
5. MVI: This instruction will move the content of data from source
to destination
6. SBB: subtract with borrow
7. HLT stops executing the program and halts any further
execution

(a) Program: Program for addition two 16-bit numbers with carry
SOURCE CODE:
LHLD 2050
XCHG
MASHIR NIZAMI (01676802818) 27 |
Page
LHLD 2052
DAD D
SHLD 3050
RST 5
FLOW CHART:

SIMULATION RESULT

Result (a)
The additions of two 16-bit numbers have concluded.
MASHIR NIZAMI (01676802818) 28 |
Page
(b) Program: Program for subtraction two 16-bit numbers with carry
SOURCE CODE:

MVI A, A5
MVI B, 66
SUB B
MVI D,00
SBB D
Hlt

FLOW CHART:

MASHIR NIZAMI (01676802818) 29 |


Page
SIMULATION RESULT

Result(b)
Subtraction of two 16-bit numbers has concluded.

MASHIR NIZAMI (01676802818) 30 |


Page
EXPERIMENT-6

Aim: Write a program for multiplication and division of two numbers


using 8085 simulator.

SOFTWARES USED: GNU SIMULATOR 8085

Theory:

1. MVI: This instruction will move the content of data from source
to destination
2. ADD R adds contents of A (Accumulator) and R register .The
result is stored in A itself.
3. SUB R subtracts contents of A (Accumulator) and R register .The
result is stored in A itself.
4. HLT stops executing the program and halts any further
execution

(a) Program: Program for multiplication of two numbers

SOURCE CODE:

MVI A,00
MVI B,04
MVI C,07
ADD C
DCR B
MASHIR NIZAMI (01676802818) 31 |
Page
JNZ 1006
Hlt

FLOW CHART:

SIMULATION RESULT

Result(a)
1C is stored in accumulator and hence the multiplication of two
numbers has concluded.

MASHIR NIZAMI (01676802818) 32 |


Page
(b) Program: Program for division of two numbers
SOURCE CODE:

MVI A,25
MVI B,05
MVI C,00
INR C
SUB B
JNZ 3007
Hlt

FLOW CHART:

MASHIR NIZAMI (01676802818) 33 |


Page
SIMULATION RESULT

Result(b)
00 is stored in accumulator and 05 is stored in BC and hence the
division of two numbers have concluded.

MASHIR NIZAMI (01676802818) 34 |


Page
EXPERIMENT-7

Aim: Write a program for addition and subtraction of two 8-bit


numbers using 8086.

SOFTWARES USED: 8086 Training Kit, Keyboard

(a) Program for addition two 16-bit numbers with carry


FLOW CHART:

Program:

MOV AX, 02 Move 02 IN AX Register


MOV AX, 04 Move 02 IN BX Register
ADD AX, BX Addition of contents of AX and BX register
INT 3

Result (a): After execution: AX=06


BX=04
MASHIR NIZAMI (01676802818) 35 |
Page
(b) Program for subtraction two 16-bit numbers with carry
FLOW CHART:

Program:
MOV AX, 04 Move 04 IN AX Register
MOV AX, 02 Move 02 IN BX Register
SUB AX, BX Subtraction of contents of AX and BX register
INT 3

Result (b): Before execution: AX=04


BX=02
After execution: AX=02
BX=02

MASHIR NIZAMI (01676802818) 36 |


Page
EXPERIMENT-8
Aim: Write a program for multiplication of two 16-bit numbers using
8086.

SOFTWARES USED: 8086 Training Kit, Keyboard

Program for multiplication of two 16-bit numbers

FLOW CHART:

Program:
Address Mnemonics
3000 A, 3000
3003 MOV AX, 1234
3006 MOV BX, 1234
3008 MUL BX
INT 3

Result: The result is stored, i.e., 25C6690

MASHIR NIZAMI (01676802818) 37 |


Page
EXPERIMENT-9

Aim: Write a program for division of two 16-bit numbers using 8086.

SOFTWARES USED: 8086 Training Kit, Keyboard

Program for division of two 16-bit numbers


FLOW CHART:

Program:
Address Mnemonics
3000 A, 3000
3003 MOV AX, 1234
3006 MOV BX, 1234
3008 DIV BX
INT 3

Result: The result is stored, i.e., 40.


MASHIR NIZAMI (01676802818) 38 |
Page
EXPERIMENT-10

Aim: Write a program for factorial of 16-bit number using 8086.

SOFTWARES USED: 8086 Training Kit, Keyboard

Program for factorial of 16-bit number


FLOW CHART:

Program:
Address Mnemonics
3000 A, 3000
3003 MOV BX
3006 MOV BX, 0001
3008 L1: MUL BX
300A DEC BX
300D JNZ 3006
INT 3

Result: The result is stored in register.


MASHIR NIZAMI (01676802818) 39 |
Page

You might also like