0% found this document useful (0 votes)
98 views

Manish Document

The program adds two 16-bit numbers stored at different memory locations and stores the result in another memory location. It uses LHLD and XCHG instructions to load the 16-bit numbers into registers HL and DE. It then uses MOV, ADD and MOV instructions to add the lower bytes and store the result in memory location 8505H. It similarly adds the upper bytes and stores the result in 8506H. This allows it to add two 16-bit numbers in memory and store the 16-bit result in another memory location.

Uploaded by

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

Manish Document

The program adds two 16-bit numbers stored at different memory locations and stores the result in another memory location. It uses LHLD and XCHG instructions to load the 16-bit numbers into registers HL and DE. It then uses MOV, ADD and MOV instructions to add the lower bytes and store the result in memory location 8505H. It similarly adds the upper bytes and stores the result in 8506H. This allows it to add two 16-bit numbers in memory and store the 16-bit result in another memory location.

Uploaded by

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

Report: Part-I

Batch: IV Sem. B.Tech CSE/IT Session: 2020-21


Course Code: 4CSU13/4ITU13 Course: Microprocessor Lab
Evaluation Scheme Internal Assessment: 50
End Term: 25
Univ.Roll No. : 19EUCIT301
Student Name MANISH PANDIT Clg. Roll No. : 19/178

SL No. Date Experiment:


01 17/04/2021 Write an introduction to 8085 Microprocessor, an 8085 kit and an 8085
simulator
02 24/04/2021 Add the 8 bit contents of memory locations XX00 H and XX01 H and
place the result in memory location XX02 H.
03 01/05/2021 Add two 16 bit numbers stored at different memory locations and store the
result in another memory location.
04 01/05/2021 Transfer a block of data which is stored at addresses starting from XX00
to another memory location starting from YY00 in forward and reverse
order. Note: Size of data block should be minimum of five.
05 08/05/2021 Write an assembly program to swap two blocks of data stored at different
memory locations
06 08/05/2021 Write an assembly program to find the square of an integer number.

07 15/05/2021 Write an assembly program to find largest and smallest number from a
given array.
08 22/05/2021 Write an assembly program to sort an array in ascending and descending
order.
EXP 1. Write an introduction to 8085 Microprocessor, an 8085 kit and an 8085 simulator.

The 8085 is a conventional von Neumann design based on the Intel 8080. Unlike the 8080 it does not
multiplex state signals onto the data bus, but the 8-bit data bus is instead multiplexed with the lower
eight bits of the 16-bit address bus to limit the number of pins to 40. State signals are provided by
dedicated bus control signal pins and two dedicated bus state ID pins named S0 and S1. Pin 40 is used
for the power supply (+5 V) and pin 20 for ground. Pin 39 is used as the Hold pin. The processor was
designed using nMOS circuitry, and the later "H" versions were implemented in Intel's enhanced nMOS
process called HMOS ("High-performance MOS"), originally developed for fast static RAM products. Only
a single 5-volt power supply is needed, like competing processors and unlike the 8080. The 8085 uses
approximately 6,500 transistors.

The 8085 incorporates the functions of the 8224 (clock generator) and the 8228 (system controller) on
chip, increasing the level of integration. A downside compared to similar contemporary designs (such as
the Z80) is the fact that the buses require demultiplexing; however, address latches in the Intel 8155,
8355, and 8755 memory chips allow a direct interface, so an 8085 along with these chips is almost a
complete system.

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


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

 8-bit data bus


 16-bit address bus, which can address upto 64KB
 A 16-bit program counter
 A 16-bit stack pointer
 Six 8-bit registers arranged in pairs: BC, DE, HL
 Requires +5V supply to operate at 3.2 MHZ single phase clock
It is used in washing machines, microwave ovens, mobile phones, etc.

8085 Microprocessor – Functional Units

8085 consists of the following functional units −

Accumulator

It is an 8-bit register used to perform arithmetic, logical, I/O & LOAD/STORE operations. It is connected
to internal data bus & ALU.
Arithmetic and logic unit

As the name suggests, it performs arithmetic and logical operations like Addition, Subtraction, AND,
OR, etc. on 8-bit data.

General purpose register

There are 6 general purpose registers in 8085 processor, i.e. B, C, D, E, H & L. Each register can hold 8-
bit data.
These registers can work in pair to hold 16-bit data and their pairing combination is like B-C, D-E & H-L.

Program counter

It is a 16-bit register used to store the memory address location of the next instruction to be executed.
Microprocessor increments the program whenever an instruction is being executed, so that the
program counter points to the memory address of the next instruction that is going to be executed.

Stack pointer

It is also a 16-bit register works like stack, which is always incremented/ decremented by 2 during push
& pop operations.

Temporary register

It is an 8-bit register, which holds the temporary data of arithmetic and logical operations.

Flag register

It is an 8-bit register having five 1-bit flip-flops, which holds either 0 or 1 depending upon the result
stored in the accumulator.
MICROPROCESSOR 8085 SIMULATOR
The simulator has two parts, an assembler (built using PEGjs) which translates 8085 assembly code to
machine code and a 8085 microprocessor simulator (written in C and compiled to JS using Emscripten)
which executes machine code. This web application is a graphical interface for the simulator.
Simulator is a graphical simulator, assembler and debugger for the Intel 8085 microprocessor
in Linux and Windows. It is among the 20 winners of the FOSS India Awards announced on February,
2008. Simulator was originally written by Sridhar Ratnakumar in fall 2003 when he realized that no
proper simulators existed for Linux. Several patches, bug fixes and software packaging have been
contributed by the GNUSim8085 community. Simulator users are encouraged to contribute to the
simulator through coding, documenting, testing, translating and porting the simulator.
EXP.02 Add the 8 bit contents of memory locations XX00 H and XX01 H and place the
result in memory location XX02H.
MEMORY LOCATION :

SOLN: 8000 H: 99H 8001 H: 39H

ADDITION : 99H+39H=D2H

1 0 0 1 1 0 0 1 (99H)
+ 0 0 1 1 1 0 0 1 (39H)
1 1 0 1 0 0 1 0 (D2H)

ALGORITHM
 Start the program by loading the first data into Accumulator.
 Move the data to a register (B register).
 Get the second data and load into Accumulator.
 Add the two register contents.
 Check for carry.
 Store the value of sum and carry in memory location.
 Terminate the program

PROGRAM ALGORITHM
LXI H 8000H  HL points 8000H
MOV A, M  Get first operand
INX H  HL points 8001H
ADD M  Add second operand
INX H  HL points 8002H
MOV M, A  Store result at 8002H
HLT  Terminate program execution

NOTE:

 Check the initial condition whether Microprocessor reset or not.


 Check the power supply.
 Be cautious while loading hexadecimal code of mnemonics.
EXP 3. Add two 16 bit numbers stored at different memory locations and store the result in
another memory location.

THEORY : Consider the first 16-bit number 02H & 03H is stored in memory location 8501H & 8502h, the
second 16-bit number 05H & 04H is stored in memory location 8503H & 8504h.The result after addition
of two numbers is to be stored in the memory location 8505 H(LSB’s sum) & 8506H(MSB’s sum). Assume
program starts from memory location 8000H

PROGRAM:

MEMORY MACHINE MNEMONICS OPERANDS COMMENTS


ADDRESS CODES
2A LHLD 8501H Get first 16-bit
8000 number in HL

8001 01 Lower byte data is


stored in memory
8002 85 Higher byte data is
stored in memory
8003 EB XCHG Save first 16-bit
number in de
8004 2A LHLD 8503 H Get second 16-bit
number in HL
8005 03 Lower byte data is
stored in memory
8006 85 Higher byte data is
stored in memory
8007 7B MOV A,E Get lower byte of
the first number
8008 95 ADD L Add lower byte of
the second
number
8009 6F MOV L,A Store the result in l
register
800A 7A MOV A,D Get higher byte of
the first number
800B 9C ADD H Add higher byte of
second number
800C 67 MOV H,A Store l6-bit result
in memory
locations
800D 22 SHLD 8505H Store l6-bit result
in memory
locations
800E 05
800F 85
8010 76 HLT Terminate
program
RESULTS:

INPUT DATA RESULT


Memory
Memory Location Data Location Data

8501 02H 8505 07H


8502 03H 8506 07H
8503 05H
8504 04H

NOTE:

 Check the initial condition whether Microprocessor reset or not.


 Check the power supply.
 Be cautious while loading hexadecimal code of mnemonics.
EXP 4. Transfer a block of data which is stored at addresses starting from XX00 to another
memory location starting from YY00 in forward and reverse order.

 Write a program to move blocks of bits from source location starting at 2500 to destination location
starting from 2600 where size of blocks is 05 bytes

Algorithm –
 Load register pair H-L with the address 2500H
 Load register pair D-E with the address 2600H
 Move the content at memory location into accumulator
 Store the content of accumulator into memory pointed by D-E
 Increment value of register pair H-L and D-E by 1
 Decrements value of register C by 1 If zero flag not equal to 1, go to step 3
 Stop
Program:
Memory address Mnemonics Operands Comments
2000 MVI C, 05 [C]<-05
2002 LXI H, 2500 [H-L]<-2500
2005 LXI D, 2500 [D-E]<-2600
2008 MOV A, M [A]<-[[H-L]]
2009 STAX D [A]<-[[D-E]]
200A INX H [H-L]<-[H-L]+1
200B INX D [D-E]<-[D-E]+1
200C DCR C [C]<-[C]-1
200D JNZ 2008 Jump if not zero to
2008
200d HLT stop

Explanation – Registers A, D, E, H, L, C are used for general


purpose:
1. MOV is used to transfer the data from memory to accumulator (1 Byte)
2. LXI is used to load register pair immediately using 16-bit address (3 Byte instruction)
3. MVI is used to move data immediately into any of registers (2 Byte)
4. STAX is used to store accumulator into register pair indirectly (3 Byte instruction)
5. DCR is used to decrease register by 1 (1 Byte instruction)
6. INX is used to increase register pair by 1 (1 Byte instruction)
7. JNZ is used to jump if not zero to given memory location (3 Byte instruction)
8. HLT is used to halt the program
EXP. 5 Write an assembly program to swap two blocks of data stored at different memory
locations
 Write an assembly level program in 8085 microprocessor to exchange a block of 4 bytes staring
from address 2001 with data starting from address 3001.

Algorithm –
 Take a count equal to 4
 Store the starting address of both blocks in 2 different register pairs
 Now exchange the contents at the addresses in both register pairs
 Increment the values of both register pairs
 Decrements count by 1
 If count is not equal to 0 repeat steps 3 to 5

PROGRAM:

Memory address Mnemonics Comments


2500 LXI D 2001 D <= 20, E <= 01
2503 LXIH 3001 H <= 20, L <= 01
2506 MVI C 04 C <= 04
2508 MOV B, M B <= M[ H-L ]
2509 LDAX D A<= M[ D-E ]
250A MOV M, A M[ H-L ] <= A
250B MOV A, B A <= B
250C STAX D M[ D-E ] <= A
250D INX H [ H-L ] <= [ H-L ] + 1
250E INX D [ D-E ] <= [ D-E ] + 1
250F DCR C C <= C – 1
2510 JNZ 2508 JUMP TO 2508 IF C NOT
EQUAL TO 0
2513 HLT STOP THE PROGRAM
Explanation –
 LXI D 2001 – Loads register pair, that is in this case, D=20 and E=01 LXI H 3001 – H=30 and L=01
 MVI C 04 – Assigns immediate data, eg.- here C=04 MVI A 45 – assigns A(accumulator) with 45,
A=45
 MOV B, M – Here M is the data in H – L register pair and it serves as an address. Copies content
at address stored in M to register B
 LDAX D – Here Accumulator is loaded with the data stored at address formed by register pair D
–E
 MOV M, A – Here A’s content is copied to address which is stored in M. MOV A, B – Copies
content of register B to A
 STAX D – Stores the content of A (accumulator) in the address formed by register pair D – E.
 INX H – Increment the content of register pair H – L
 INX H – Increment the content of register pair D – E
 DCR C – Decrements the content of register C
 JNZ 2508 – If value of register C is not equal to 0 then jump to address 2508
 HLT – Stop execution of program
EXP 6. Write an assembly program to find the square of an integer number
Theory: The squares of number are stored in certain memory locations in tabular form. This table is
called look-up table. Here squares of numbers from 00 to 09 are stored at locations 2600 to 2609h. All
these values are in decimal numbers. The program given below is self explanatory.

Procedure:-

 To Feed the program and data in the RAM, for machine language follow the steps 7 to 9 and for
assembly language programming steps 10 to 14.
 Press [M][ENTER]. Starting address here is 2000H, so syntax will be [M][ENTER].
 The LCD display will show the address and its content. Modify the content according to the
program using keyboard then press [ENTER] or [SPACEBAR]. The content will be saved and
display will move the next address. Modify if required.
 Use UP/DOWN arrow keys move between the memory locations.
 Press [1][A] to select assembler mode.
 The display will show ‘RAM ADR: [BLANK]’, asking for the starting address which is 2000H in the
above program.
 Type [2000] and press [ENTER].
 Display will show ‘2000: [BLANK]’. Type the mnemonics of the command operand etc. and press
[ENTER].
 The display will show the next location. Type desired mnemonics and operand. Keep on doing
this until the end of the program.
 Feed the data using the [M] command.
 To RUN/ EXECUTE the program Press [G][$].
 Go to memory locations used for result storage using [M] command and verify the results.

Program:

Memory Machine Mnemonics operands Comments


2000 3A,00,25 LDA 2500 H Get number in
accumulator
2003 6F MOV L,A Move From A
into reg. L
2004 26,26 MVI H,26H Get 26 in reg.H

2006 7E MOV A,M Square of data


In accumulator
2007 32,01,25 STA 2501 H Store square in
2501 H.
200A 76 HLT Stop
Results:

Memory Address Data


2600H 00
2601H 01
2602H 04
2603H 09
2604H 16
2605H 25
2606H 36
2607H 49
2608H 64
2609H 81

Input Data: 2500H- 07D

Output Data: 2503H- 49D

Precautions:-

(1) Make sure proper handling of equipments / kits.

(2) Make sure that all the machine codes / mnemonics are as per the program.
EXP 7. Write an assembly program to find largest and smallest number from a given array.

Let the list be:

42H 21H 01H 1FH FFH 25H 32H 34H 0AH ABH

Minimum: 01H Maximum: FFH


 In CMP instruction:
If Accumulator > Register then carry and zero flags are reset
If Accumulator = Register then zero flag is set
If Accumulator < Register then carry flag is set

Let the list of numbers be from 2050H to 2059H and output at 2060H and 2061H.

Algorithm:

 Maximum number is stored in B register and minimum in C register


 Load counter in D register
 Load starting element in Accumulator, B and C register
 Compare Accumulator and B register
 If carry flag is not set then transfer contents of Accumulator to B. Else, compare Accumulator with C register, if
carry flag is set transfer contents of Accumulator to C
 Decrement D register
 If D>0 take next element in Accumulator and go to point 4
 If D=0, store B and C register in memory
 End of program
Program:

Address Label instruction Comment


2000H LXI H, 2050H Load starting address of
list
2003H MOV B, M Store maximum
2004H MOV C, M Store minimum
2005H MVI D, 0AH Counter for 10 elements
2007H LOOP MOV A, M Retrieve list element in
accumulator
2008H CMP B Compare element with
maximum number
2009H JC MIN Jump to MIN if not
maximum
200CH MOV B, A Transfer contents of A to B
as A>B
200DH MIN CMP C Compare element with
minimum number
200EH JNC SKIP Jump to SKIP if not
minimum
2011H MOV C, A Transfer contents of A to C
if A <minimum
2012H SKIP INX H Increment memory
2013H DCR D Decrement counter
2014H JNZ LOOP Jump to LOOP if D>0

2017H LXI H, 2060H Load address to store


maximum
201AH MOV M,B Move maximum to 2060H

201BH INX H Increment memory

201CH MOV M,C Move minimum to 2061H

201DH HALT Halt

Explanation –
 One by one all elements are compared with B and C register.
 Element is compared with maximum, if it greater than maximum then it is stored in B register. Else,
it is compared with minimum and if it is less than minimum, then it stored in C register.
 Loop executes 10 number of times.
 At the end of 10 iterations, maximum and minimum are stored at 2060H and 2061H respectively.

Precautions:-
(1) Make sure proper handling of equipments/ kits.

(2) Make sure that all the machine codes/ mnemonics are as per the program.
EXP. 8 Write an assembly program to sort an array in ascending and descending order.
Problem – Write an assembly language program in 8085 microprocessor to sort a given list of n numbers
using Bubble Sort. Size of list is stored at 2040H and list of numbers from 2041H onwards.

Algorithm:

 Load size of list in C register and set D register to be 0


 Decrement C as for n elements n-1 comparisons occur
 Load the starting element of the list in Accumulator
 Compare Accumulator and next element
 If accumulator is less than or equal to the next element jump to step 8
 Swap the two elements
 Set D register to 1
 Decrement C
 If C>0 take next element in Accumulator and go to point 4
 If D=0, this means in the iteration, no exchange takes place consequently we know that it won’t take
place in further iterations so the loop in exited and program is stopped
 Jump to step 1 for further iterations

PROGRAM:
Address Instruction Comment
2000H LXI H, 2040H Load size of array
2003H MVI D, 00H Clear D register to set up a flag
2005H MOV C, M Set C register to set up a flag
2006H DCR C Decrement C
2007H INX H Increment memory to access list
2008H MOV A, M Retrieve list element in Accumulator

2009H INX H Increment memory to access next


element
200AH CMP M Compare Accumulator with next
element
200BH JC NEXTBYTE If accumulator is less then jump to
NEXTBYTE
200EH JZ NEXTBYTE If accumulator is equal then jump to
NEXTBYTE
2011H MOV B, M Swap the two elements
2012H MOV M, A
2013H DCX H
2014H MOV M, B
2015H INX H
2016H MVI D, 01H If exchange occurs save 01 in D
register
2018H DCR C Decrement C for next iteration
2019H JNZ CHECK Jump to CHECK if C>0
201CH MOV A, D Transfer contents of D to
Accumulator
201DH CPI 01H Compare accumulator contents with
01H
201FH JZ START Jump to START if D=01H
2022H HLT HALT
Explanation-
 Retrieve an element in accumulator.
 Compare it with next element, if it is greater than swap otherwise move to next index.
 If in one entire loop there has been no exchange, halt otherwise start the whole iteration again.
 The following approach has two loops, one nested inside other so-
 Worst and Average Case Time Complexity: O(n*n). Worst case occurs when array is reverse sorted.
 Best Case Time Complexity: O (n). Best case occurs when array is already sorted.

You might also like