Professional Documents
Culture Documents
MP Lab File-2
MP Lab File-2
(KCS-452)
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
End
Program:
Flowchart:
Start
st
Get the 1 no.
nd
Get the 2 no.
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.
End
Program:-
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.
End
Program:-
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.
End
Program:
Flowchart:
Start
st
Get the 1 no.
nd
Get the 2 no.
End
Program:
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
Is Carry?
Increment D register
No
Is zero?
If Yes
END
Program:
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
Quotient=0
.Division=Dividend-Divisor
No
Quotient=Quotient+1
Is dividend<disisor?
If Yes
Remainder=dividend
END
Program:
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
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
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.
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
HL=HL-1
End
Program:
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.
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
Increament H-L pair to point to first number’s Move data from register B to
memory location accumulator
Decreament counter C
NO
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:
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
Compare B with A
NO
Is carry?
YES
END
Program:
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.