Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

MICROPROCESSOR LAB

(KCS-452)

Submitted To: Ms Rikendra Poonia Submitted By: Suyash Tripathi


Roll no.: 1901920100293

Department of Computer Science & Engineering

G L Bajaj Institute of Technology and Management


Greater Noida – 201306
INDEX

S. Name of Experiment Date of Date of Signature of


Page No.
No. Experiment Submission Faculty with
date
1 9/4/2021 9/4/2021
Write a program using 8085
Microprocessor for Decimal, Hexadecimal
addition and subtraction of two Numbers.
2 Write a program using 8085 Microprocessor 16/4/2021 16/4/2021
for addition and
subtraction of two BCD numbers.
3 To perform multiplication of two 8 bit 23/4/2021 23/4/2021
numbers using
8085.
4 To perform division of two 8 bit numbers 27/5 2021 27/5/2021
using 8085
5 To write a program to arrange an array of 10/6 2021 10/6/2021
data in ascending using 8085.
6 To write a program to arrange an array of 3/6/2021 3/6/2021
data in descending order using 8085
7 To perform BCD addition using 8085. 17/6/2021 17/6/2021

8 To swap two numbers and exchange the 1/7/2021 1/7/2021


contents of ML 0000H &0001H

9 To find the smallest number in an array of 8/7/2021 8/7/2021


data using 8085 instruction set

10 To find the largest number in an array of 8/7/2021 8/7/2021


data using 8085 instruction set
EXPERIMENT 1
Aim: Write a program using 8085 Microprocessor for Decimal, Hexadecimal addition and subtraction
of two Numbers.

Apparatus Required:
S. No. Name of Specification/ Range/ Quantity
Equipment/Software/ Rating
Equipment
1. GNUSim8085, Desktop 01
2. Power supply A.C (230V Mains)

Algorithm
Hexadecimal Addition:
The program takes the content of 2009, adds it to 200B & stores the result back at 200C.
Steps:
1. Initialize HL Reg. pair with address where the first number is lying.
2. Store the number in accumulator.
3. Get the second number.
4. Add the two numbers and store the result in 200B.
5. Go back to Monitor

Flowchart:

Start

Get the 1st no.

Get the 2nd no.

Add two no.

Store the result

End
Program:

Memory location Level Mnemonics Remarks


2000 LXI H, 2009 Point 1st no.
MOV A, M Load the acc.
2003 INX H Adv Pointer
ADD M
INX H Add IIND NO
2005
MOV M, A Adv Pointer
2007 HLT Store Result
Decimal Addition:
Steps:
1. Initialize HL Reg. pair with address where the first number is lying.
2.Store the number in accumulator.
3.Get the second number.
4.Add the two numbers and store the result in 200B.
5.Go back to Monitor

Flowchart:

Start

st
Get the 1 no.

nd
Get the 2 no.

Add two no.

Adjust the decimal

Store the result

End
Memory location Level Mnemonics Remarks
2000 LXI H, 2009 Point 1st no.
MOV A, M Load the acc.
2003 INX H Adv Pointer
ADD M
DAA Add IIND NO
2005
Adjust the decimal
2007 INX H
Adv Pointer
2008 MOV M,A
Store Result
2009 HLT

Result:-
Thus the numbers at 2009H and at memory are added.

Hexadecimal Subtraction:
The program takes the content of 2009, subtracts it to 200B & stores theresult back at
200C.
Steps:-

1.Initialize HL Reg. pair with address where the first number is lying.
2.Store the number in accumulator.
3.Get the second number.
4.Subtract second no from acc and store the result in 200B.
5.Go back to Monitor
Flowchart:

Start

st
Get the 1 no.

nd
Get the 2 no.

Sub. second no.

Store the result

End

Program:-

Memory location Level Mnemonics Remarks


2000 LXI H, 2009 Point 1st no.
MOV A, M Load the acc.
2003 INX H Adv Pointer
SUB M
INX H Subtract IIND NO
2005
MOV M, A Adv Pointer
2007 HLT Store Result
Decimal Subtraction :

Steps:-

1.Initialize HL Reg. pair with address where the first number is lying.
2.Store the number in accumulator.
3.Get the second number.
4.Subtract second no from acc and store the result in 200B.
5.Adjust the decimal
6.Go back to Monitor

FLOWCHART:-

Start

st
Get the 1 no.

nd
Get the 2 no.

Sub two no.

Adjust the decimal

Store the result

End
Program:-

Memory location Level Mnemonics Remarks


2000 LXI H, 2009 Point 1st no.
MOV A, M Load the acc.
2003 INX H Adv Pointer
SUB M
DAA Subtract IIND NO
2005
Adjust the decimal
2007 INX H
MOV M,A Adv Pointer
2008 Store Result
2009 HLT
200C

Result:
Numbers at 2009H and in HL pairs (Memory) are subtracted

Conclusion:
Thus the addition and subtraction operation is taken out using assembly language.

Precaution:
1.Verify the hex code before executing in program.
2.The memory allocation according to model of the kit.
EXPERIMENT 2
Aim: Write a program using 8085 Microprocessor for addition and subtraction of two BCD
numbers.

Apparatus Required:
S. No. Name of Specification/ Range/ Quantity
Equipment/Software/ Rating
Equipment
1. GNUSim8085, Desktop 01
2. Power supply A.C (230V Mains)

Algorithm:
Addition:
1.Load 00H in a register (for carry)
2.Load content from memory into register pair
3.Move content from L register to accumulator
4.Add content of H register with accumulator
5.Add 06H if sum is greater than 9 or Auxiliary Carry is not zero
6.If carry flag is not equal to 1, go to step 8
7.Increment carry register by 1
8.Store content of accumulator into memory
9.Move content from carry register to accumulator
10.Store content of accumulator into memory
11.Stop
Flowchart:

Start

st
Get the 1 no.

nd
Get the 2 no.

Add two no.

Adjust the decimal

Store the result

End

Program:

Memory location Level Mnemonics Remarks


2000 MVI C,00H Carry
LHLD 2500H Store no. in memory
2003 MOV A,L [A]<-[L]
ADD H
DAA [A]<-[A]+[H]
2005
Jump if no carry
2007 JNC 200C
INR C [C]<-[C]+1
2008 [A]->[2502],Sum
200C STA 2502H
200F MOV A,C [A]<-[C]
2010 STA 2503 H [A]->2503,Carry
2013 HLT
Stop
Algorithm:
Subtraction:
1.Load the data from address 2051 in A
2.Move the data from A to C
3.Move the data 99 in A
4.Subtract the contents of registers A and C
5.Increment the content of A by 1
6.Move the data from A to B
7.Load the data from address 2050 in A
8.Add the contents of A and C and adjust it in BCD format by using DAA instruction
9.Store the result at memory address 3050
10.Stop

Flowchart:

Start

st
Get the 1 no.

nd
Get the 2 no.

Sub two no.

Adjust the decimal

Store the result

End
Program:

Memory location Level Mnemonics Remarks


2000 LDA 2051H [A]<-[2051]
MOV C,A [C]<-[A]
2003 [A]<-[99H]
MVI A,99H
SUB C [A]<-[A]-[C]
2005 INR A [A]<-[A]+1
MOV B,A [B]<-[A]
2007
LDA 2050H [A]<-[2050]
2008 [A]<-[A]+[B]
200C ADD B
200F DAA
STA 3050H [3050]<-[A]
2010
2013 HLT Stop

Result:
The BCD numbers at 2009H and memory are added and subtracted.

Conclusion:
Thus the addition and subtraction operation is taken out using assembly language.

Precaution:
1.Verify the hex code before executing in program.
2.The memory allocation according to model of the kit.
EXPERIMENT 3
Aim:To perform multiplication of two 8 bit numbers using 8085.
Apparatus Required:
S. No. Name of Specification/ Range/ Quantity
Equipment/Software/ Rating
Equipment
1. GNUSim8085, Desktop 01
2. Power supply A.C (230V Mains)

Algorithm:
1.We are taking adding the number 43 seven(7) times in this example.
2.As the multiplication of two 8 bit numbers can be maximum of 16 bits so we need
register pair to store the result.
Flowchart:

START

Initialize register A &


D reg. to zero

Get 1st no.

Get 2nd no.

Add 1st no. to content of A reg.

Is Carry?

Increment D register
No

Decrement 2nd no.

Is zero?

If Yes

Store the result

END
Program:

Memory location Level Mnemonics Remarks


2000 LHLD 2050H [H]<-[2051],[L]<-[2050]
XCHG [H]<->[D],[L]<->[E]
2003 [C]<-[D]
MOV C,D
MVI D,00H [D]<-00
2005 LXI H,0000H [H]<-00,[L]<-00
DAD D [HL]<-[HL]+[DE]
2007 LOOP:
DRC C [C]<-[C]-1
2008
200C JNZ LOOP
[H]->[3051],[L]->[3050]
200F SHLD 3050H
HLT Stop
2010

Result:
Input: 07 (2051)
43 (2050)
Output: 01 (3051)
D5 (3050)

Conclusion:
Thus the multiplication process is taken out using assembly language for 8085
microprocessor.

Precaution:
1.Verify the hex code before executing in program.
2.The memory allocation according to model of the kit.
EXPERIMENT 4
Aim:To perform division of two 8 bit numbers using 8085.
Apparatus Required:
S. No. Name of Specification/ Range/ Quantity
Equipment/Software/ Rating
Equipment
1. GNUSim8085, Desktop 01
2. Power supply A.C (230V Mains)

Algorithm:
1.Start the program by loading the HL pair registers with address of memory location.
2.Move the data to B Register.
3.Load the second data into accumulator.
4.Compare the two numbers to check carry.
5.Subtract two numbers.
6.Increment the value of carry.
7.Check whether the repeated subtraction is over.
8.Then store the results(quotient and remainder) in given memory location.
9.Terminate the program.
Flowchart:

START

Get the dividend

Get the divisor

Quotient=0

.Division=Dividend-Divisor

No
Quotient=Quotient+1

Is dividend<disisor?

If Yes

Remainder=dividend

Store the quotient and remainder

END
Program:

Memory location Level Mnemonics Remarks


2000 LXI H,2050
MOV B,M [B]<-[M]
2003 [C]<-00H
MOV C,00

2005 INX H
MOV A,M [A]<-[M]
2007
2008 LOOP 1: CMP B
Check for carry
200C JC LOOP
[A]<-[A]-[B]
200F SUB B
INR C [C]=[C]+1
2010
JMP LOOP1 [3050]<-[A]
LOOP: STA 3050
[A]<-[C]
MOV A,C
[3051]<-[A]
STA 3051
HLT Stop

Result:
Input: FF (2051)
FF (2050)
Output: 01 (3051)
FE (3050)

Conclusion:
Thus the division process is taken out in 8085 microprocessor.

Precaution:
1.Verify the hex code before executing in program.
2.The memory allocation according to model of the kit.
EXPERIMENT 5
Aim:To write a program to arrange an array of data in ascending order using 8085.
Apparatus Required:
S. No. Name of Specification/ Range/ Quantity
Equipment/Software/ Rating
Equipment
1. GNUSim8085, Desktop 01
2. Power supply A.C (230V Mains)

Algorithm:
1.Initialize HL pair as memory pointer
2.Get the count at 4200 into C – register
3.Copy it in D – register (for bubble sort (N-1) times required)
4.Get the first value in A – register
5.Compare it with the value at next location.
6.If they are out of order, exchange the contents of A –register and Memory
7.Decrement D –register content by 1
8.Repeat steps 5 and 7 till the value in D- register become zero
9.Decrement C –register content by 1
10.Repeat steps 3 to 9 till the value in C – register becomes zero
Flowchart:
Program:
Memory location Level Mnemonics Remarks

2000 LXI H,4200


MOV C,M
2003 DCR C
REPEAT: MOV D,C
2005 LXI H,4201
LOOP: MOV A,M
2007 INX H
CMP M
2008 JC SKIP
MOV B,M
2009 MOV M,A
DCX H
200C MOV M,B
INX H
200D SKIP: DCR D
JNZ LOOP
DCR C
200E JNZ REPEAT
HLT
200F

2010

Result:
Input at: 3000= 05 H

3001= 05 H

3002= 04 H

3003= 03H

3004= 02H

3005= 01H
Output at: 3001= 01 H
3002=02H
3003=03H
3004=04H
3005=05H
Conclusion
Array of data in ascending order has been placed successfully.

Precaution:
1.Verify the hex code before executing in program.
2.Tke memory allocation according to model of the kit.
EXPERIMENT 6
Aim:To write a program to arrange an array of data in descending order using 8085.
Apparatus Required:
S. No. Name of Specification/ Range/ Quantity
Equipment/Software/ Rating
Equipment
1. GNUSim8085, Desktop 01
2. Power supply A.C (230V Mains)

Algorithm:
1.Initialize HL pair as memory pointer
2.Get the count at 4200 into C – register
3.Copy it in D – register (for bubble sort (N-1) times required)
4.Get the first value in A – register
5.Compare it with the value at next location.
6.If they are out of order, exchange the contents of A –register and Memory
7.Decrement D –register content by 1
8.Repeat steps 5 and 7 till the value in D- register become zero
9.Decrement C –register content by 1
10.Repeat steps 3 to 9 till the value in C – register becomes zero
Flowchart:
Program:
Memory location Level Mnemonics Remarks

2000 LXI H,4200


MOV C,M
2003 DCR C
REPEAT: MOV D,C
2005 LXI H,4201
LOOP: MOV A,M
2007 INX H
CMP M
2008 JNC SKIP
MOV B,M
2009 MOV M,A
DCX H
200C MOV M,B
INX H
200D SKIP: DCR D
JNZ LOOP
DCR C
200E JNZ REPEAT
HLT
200F

2010

Result:
Input at: 3000= 05 H
3001= 01 H
3002= 02 H
3003= 03H
3004= 04H
3005= 05H

Ouput at:
3001= 05 H
3002= 04 H
3003= 03H
3004= 02H
3005= 01H
Conclusion:
Array of data in descending order has been placed successfully.

Precaution:
1.Verify the hex code before executing in program.
2.The memory allocation according to model of the kit.
EXPERIMENT 7
Aim:To perform BCD addition using 8085.
Apparatus Required:
S. No. Name of Specification/ Range/ Quantity
Equipment/Software/ Rating
Equipment
1. GNUSim8085, Desktop 01
2. Power supply A.C (230V Mains)

Algorithm:
1.Load 00H in a register (for carry)
2.Load content from memory into register pair
3.Move content from L register to accumulator
4.Add content of H register with accumulator
5.Add 06H if sum is greater than 9 or Auxiliary Carry is not zero
6.If carry flag is not equal to 1, go to step 8
7.Increment carry register by 1
8.Store content of accumulator into memory
9.Move content from carry register to accumulator
10.Store content of accumulator into memory
11.Stop
Flowchart:

Start

st
Get the 1 no.

nd
Get the 2 no.

Add two no.

Adjust the decimal

Store the result

End

Program:
Memory location Level Mnemonics Remarks
2000 MVI C,00H Carry
LHLD 2500H Store no. in memory
2003 MOV A,L [A]<-[L]
ADD H
DAA [A]<-[A]+[H]
2005
Jump if no carry
2007 JNC 200C
INR C [C]<-[C]+1
2008 [A]->[2502],Sum
200C STA 2502H
200F MOV A,C [A]<-[C]
2010 STA 2503 H [A]->2503,Carry
2013 HLT
Stop
Result:
The BCD numbers at 2009H and memory are added.

Conclusion:
Thus the addition operation is taken out using assembly language.

Precaution:
1.Verify the hex code before executing in program.
2.The memory allocation according to model of the kit.
EXPERIMENT 8
Aim: To swap two numbers and exchange the contents of HL 0000H &0001H
Apparatus Required:
S. No. Name of Specification/ Range/ Quantity
Equipment/Software/ Rating
Equipment
1. GNUSim8085, Desktop 01
2. Power supply A.C (230V Mains)

Algorithm:
Swap two numbers:
1.Load accumulator with the content of any one location .
2.Move the contents of accumulator to any register so that another location’s content can
be loaded to accumulator and the previous data of accumulator get saved in register.
3.Store the content of accumulator to another location .
4.Load accumulator with content of register and then store it to another address location.
Flowchart:

Start

HL=1st no.address

B=1st no.

HL=HL+1
A=2nd adresss

Store B at location pointed by HL

HL=HL-1

Store A at location pointed by HL

End
Program:

Memory location Level Mnemonics Remarks


2000 LDA 2500H [A]<-[2500]
MOV B,A [B]<-[A]
2003 LDA 2501H [A]<-[2501]
STA 2500H
MOVA,B [2500]<-[A]
2005
[A]<-[B]
2007 STA 2501H
HLT [2501]<-[A]
2008 Stop
2009
200C

Algorithm:
Exchange content of HL register pair
1.Initialize stack pointer (SP) by 3FFF.
2.Push the content of H and L register into the stack. Decrements SP by 2.
3.Push the content of D and E register into the stack. Decrements SP by 2.
4.Pop the upper two bytes from top of stack and place it in HL register. Increment SP by 2.
5.Pop the remaining two bytes from top of stack and place it in DE register. Increment SP
by 2.
Flowchart:

Start

st
H=1 no.

D=2nd no.

Exchange DE and HL content

Store H at 1st place.


Store D at 2nd place

End

Program:
Memory location Level Mnemonics Remarks
2000 LXI SP,3FFF
PUSH H
2003 PUSH D
POP H
2005 POP D
2007 HLT
Result:

Conclusion:
Thus the swapping the two numbers and exchange the contebt of HL register is taken out
using assembly language.

Precaution:
1.Verify the hex code before executing in program.
2.The memory allocation according to model of the kit.
EXPERIMENT 9
Aim: To find the smallest number in an array of data using 8085 instruction set
Apparatus Required:
S. No. Name of Specification/ Range/ Quantity
Equipment/Software/ Rating
Equipment
1. GNUSim8085, Desktop 01
2. Power supply A.C (230V Mains)

Algorithm:
1. Load the address of the first element of the array in HL pair.
2. Move the count to B - reg.
3. Increment the pointer.
4. Get the first data in A - reg.
5. Decrement the count.
6. Increment the pointer.
7. Compare the content of memory addressed by HL pair with that of A - reg.
8. If carry = 1, go to step 10 or if Carry = 0 go to step 9.
9. Move the content of memory addressed by HL to A - reg.
10. Decrement the count.
11. Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to next step.
12. Store the smallest data in memory.
13. Terminate the program.
Flowchart:

START

Load H-L pair with address of counter’s YES


memory location
Is carry?

Move counter from memory to register C


NO

Increament H-L pair to point to first number’s Move data from register B to
memory location accumulator

Move the first number from memory to register A


Decreament counter C

Decreament counter C
NO

Increament H-L pair to point to next number’s Is carry?


memory location

YES
Move the next number from memory to register B
Increament H-L pair

Compare B with A
Move the result from accumulator to
memory

END
Program:

Memory location Level Mnemonics Remarks


2000 LXI H,5000H Set pointer for array
MOV B,M Load the Count
2003 INX H
MOV A,M
DCR B Set 1st element as smallest data
2005
Decrement the count
2007 LOOP: INX H
2008 CMP M
If A- reg < M go to AHEAD
200C JC AHEAD
200F MOV A,M Set the new value as smallest
2010 AHEAD: DCR B
2013 JNZ LOOP
Repeat comparisons till count = 0
STA 6000H
Store the smallest value at 6000
HLT

Result:
Input at:
Data 0: 05H in memory location 5000 --> Array Size
Data 1: 0AH in memory location 5001
Data 2: F1H in memory location 5002
Data 3: 1FH in memory location 5003
Data 4: 26H in memory location 5004
Data 6: FEH in memory location 5005

Output:
Smallest Data : 0AH in memory location 6000
Conclusion:
Thus the smallest number in an array of data is taken out using assembly language.

Precaution:
1.Verify the hex code before executing in program.
2.The memory allocation according to model of the kit.
EXPERIMENT 10
Aim: To find the largest number in an array of data using 8085 instruction set
Apparatus Required:
S. No. Name of Specification/ Range/ Quantity
Equipment/Software/ Rating
Equipment
1. GNUSim8085, Desktop 01
2. Power supply A.C (230V Mains)

Algorithm:
1. Load the address of the first element of the array in HL pair
2. Move the count to Bn- reg.
3. Increment the pointer
4. Get the first data in A - reg.
5. Decrement the count.
6. Increment the pointer
7. Compare the content of memory addressed by HL pair with that of A - reg.
8. If Carry = 0, go to step 10 or if Carry = 1 go to step 9
9. Move the content of memory addressed by HL to A - reg.
10. Decrement the count
11. Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to next step.
12. Store the largest data in memory. 13. Terminate the program.
Flowchart:

START

Load H-L pair with address of first operand’s


memory location

Move the first operand from memory to


accumulator

Increament H-L pair to point next memory


location

Move the second operand from memory to


register B

Compare B with A

NO
Is carry?

YES

Move data from register B to accumulator

Increament H-L pair

Move the result from accumulator to


memory

END
Program:

Memory location Level Mnemonics Remarks


2000 LXI H,5000H Set pointer for array
MOV B,M Load the Count
2003 INX H
MOV A,M
DCR B Set 1st element as largest data
2005
Decrement the count
2007 LOOP: INX H
2008 AHEAD: DCR B
If A- reg > M go to AHEAD
200C CMP M
200F JNC AHEAD Set the new value as largest
2010 MOV A,M
2013 JNZ LOOP
Repeat comparisons till count = 0
STA 6000H
Store the smallest value at 6000
HLT

Result:
Input at:
Data 0: 05H in memory location 5000 --> Array Size
Data 1: 0AH in memory location 5001
Data 2: F1H in memory location 5002
Data 3: 1FH in memory location 5003
Data 4: 26H in memory location 5004
Data 6: FEH in memory location 5005

Output:
Largest Data : FEH in memory location 6000
Conclusion:
Thus the largest number in an array of data is taken out using assembly language.

Precaution:
1.Verify the hex code before executing in program.
2.The memory allocation according to model of the kit.

You might also like