Sunteți pe pagina 1din 27

MICROPROCESSORS LABORATORY

MP-408

Abhay Menon A
I15PH010
M.Sc. Physics
Semester VIII
Even Semester

1
CERTIFICATE

This is to certify that ABHAY MENON A, roll number I15PH010, is a


bonafide student of SARDAR VALLABHBHAI NATIONAL
INSTITUTE OF TECHNOLOGY, pursuing 4th YEAR, VIII
SEMESTER, INTEGRATED M.Sc. IN PHYSICS, and has completed
all the experiments regarding the MP-408 MICROPROCESSORS
LABORATORY in the academic year 2018-19.

Sign of Teacher Seal of Institution

2
Table of Contents

# Name Date Grade


1 Add ten data bytes 13/02/19
2 Swap numbers in reverse order 13/03/19
3 Generate 10 Fibonacci numbers 13/03/19
4 Arrange data bytes in ascending order 20/03/19
5 Arrange data bytes in descending order 20/03/19
6 Count Positives, negatives and zeroes in a given data byte sample set 27/03/19
7 Count odd, even and zeroes in a given data byte sample set 27/03/19
8 Convert given BCD numbers into Hex 03/04/19
9 Convert given Hex numbers into BCD 03/04/19
10 Count the number of vowels in given data set 03/04/19
11 Interface 8255 with 8085 and turn on LEDs 03/04/19
12 Make a running LED pattern with a time gap of 0.77 seconds 03/04/19

3
EXPERIMENT-1

• AIM: To write an 8085 program to add 10 bytes of data stored from memory location
C100H to C109H and save the answer in memory location C200H.

• MNEMONICS AND HEX CODE:

Lower order address Higher order


Starting Address Instruction Hex Code
Byte/8 bit data address Byte
C000H LXI H, C100H 21 00 C1
C003H MVI D, 0AH 16 0A
C005H MOV A,M 7E
C006H INX H 23
C007H ADC M 8E
C008H DCR D 15
C009H JNZ C005H C2 05 C0
C00CH STA C200H 32 00 C2
C00FH RST-1 CF

• COMMENTS:

1. Register D is used as a counter for 10 data bytes, and hence is initialized with the
value 0AH.
2. Registers H and L are loaded with data pointing towards the memory location that
is required.

4
• RESULTS:

– Input:

Address value
C100H 01H
C101H 02H
C102H 03H
C103H 04H
C104H 05H
C105H 06H
C106H 07H
C107H 08H
C108H 09H
C109H 0AH

– Output:

Address value
C200H 37H

• CONCLUSION:
This program successfully adds numbers and stores them in a
specified location.

5
EXPERIMENT-2

• AIM: To write an 8085 program to reverse the order of 10 bytes stored from memory
locations C000H to C009H, and to store them in the same locations.

• MNEMONICS AND HEX CODE:

Lower order address Higher order


Starting Address Instruction Hex Code
Byte/8 bit data address Byte
D000H MVI B, 0AH 06 0A
D002H LXI H, C000H 21 00 C0
D005H LXI D, F000H 11 00 F0
D008H MOV A,M 7E
D009H STAX D 12
D00AH INX D 13
D00BH INX H 23
D00CH DCR B 05
D00DH JNZ D008H C2 08 D0
D010H MVI C, 0AH 0E 0A
D012H LXI H, C009H 21 09 C0
DO15H LXI D, F000H 11 00 F0
D018H LDAX D 1A
D019H MOV M,A 77
D01AH INX D 13
D01BH DCX H 2B
D01CH DCR C 0D
D01DH JNZ D018H C2 18 D0
D020H RST-1 CF

• COMMENTS:

1. Registers B and C are used as counters for 10 data bytes, and hence are initialized
with the value 0AH.
2. Registers H and L are loaded with data pointing towards the memory location that
is required.
3. We utilize a different memory space to temporarily store the values, and then transfer
them back in reverse order.

6
• RESULTS:

– Input:

Address value
C000H 00H
C001H 01H
C002H 02H
C003H 03H
C004H 04H
C005H 05H
C006H 06H
C007H 07H
C008H 08H
C009H 09H

– Output:

Address value
C000H 09H
C001H 08H
C002H 07H
C003H 06H
C004H 05H
C005H 04H
C006H 03H
C007H 02H
C008H 01H
C009H 00H

• CONCLUSION:
This program successfully reverses the order of data bytes starting
from a particular specified location.

7
EXPERIMENT-3

• AIM: To write an 8085 program to generate 10 Fibonacci numbers and store them in
memory locations starting from C000H.

• MNEMONICS AND HEX CODE:

Lower order address Higher order


Starting Address Instruction Hex Code
Byte/8 bit data address Byte
E000H MVI B, 09H 06 09
E001H LXI H, C000H 21 00 C0
E005H MVI M, 00H 36 00
E007H INX H 23
E008H MVI M, 01H 36 01
E00AH SUM: DCX H 2B
E00BH MOV A,M 7E
E00CH INX H 23
E00DH ADD M 86
E00EH INX H 23
E00FH MOV M, A 77
E010H DCR B 05
E011H JNZ SUM C2
E012H RST-1 CF

• COMMENTS:

1. Register B is taken as a counter, and is initialized with the value 09H, since the first
2 values are given already.
2. The registers H and L are loaded with the pointer to the memory location where the
numbers are to stored.

8
• RESULTS:

– Output:

Address value
C000H 00H
C001H 01H
C002H 01H
C003H 02H
C004H 03H
C005H 05H
C006H 08H
C007H 0DH
C008H 15H
C009H 22H

• CONCLUSION:
This program successfully generates Fibonacci numbers, given that
the initial values are supplied to the program.

9
EXPERIMENT-4

• AIM: To write an 8085 program to arrange a list of 10 numbers in ascending order,


starting from memory location C500H.

• MNEMONICS AND HEX CODE:

Lower order address Higher order


Starting Address Instruction Hex Code
Byte/8 bit data address Byte
D000H MVI B,0AH 06 0A
D002H MVI C,0AH 0E 0A
D004H LXI H, C500H 21 00 C5
D007H MOV A,M 7E
D008H INX H 23
D009H CMP M BE
D00AH JC D015H DA 15 D0
D00DH JZ D015H CA 15 D0
D010H MOV D,M 56
D011H MOV M,A 77
D012H DCX H 2B
D013H MOV M,D 72
D014H INX H 23
D015H DCR C 0D
D016H JNZ D007H C2 07 D0
D019H DCR B 05
D01AH JNZ D002H C2 02 D0
D01DH RST-1 CF

• COMMENTS:

1. Registers B and C were used as counters, and are initialized with the value 0AH.
2. Registers H and L were loaded with values pointing to memory location C500H.
3. We use the Compare function, and then change the locations if both carry and zero
flags are not set.

10
• RESULTS:

– Input:

Address value
C500H 09H
C501H 08H
C502H 07H
C503H 06H
C504H 05H
C505H 04H
C506H 03H
C507H 02H
C508H 01H
C509H 00H

– Output:

Address value
C500H 00H
C501H 01H
C502H 02H
C503H 03H
C504H 04H
C505H 05H
C506H 06H
C507H 07H
C508H 08H
C509H 09H

• CONCLUSION:
The above program successfully sorts the list of numbers in as-
cending order.

11
EXPERIMENT-5

• AIM: To write an 8085 program to arrange a list of 10 numbers in descending order,


starting from memory location C500H.

• MNEMONICS AND HEX CODE:

Lower order address Higher order


Starting Address Instruction Hex Code
Byte/8 bit data address Byte
D000H MVI B,0AH 06 0A
D002H MVI C,0AH 0E 0A
D004H LXI H, C500H 21 00 C5
D007H MOV A,M 7E
D008H INX H 23
D009H CMP M BE
D00AH JNC D015H D2 15 D0
D00DH JZ D015H CA 15 D0
D010H MOV D,M 56
D011H MOV M,A 77
D012H DCX H 2B
D013H MOV M,D 72
D014H INX H 23
D015H DCR C 0D
D016H JNZ D007H C2 07 D0
D019H DCR B 05
D01AH JNZ D002H C2 02 D0
D01DH RST-1 CF

• COMMENTS:

1. Registers B and C were used as counters, and are initialized with the value 0AH.
2. Registers H and L were loaded with values pointing to memory location C500H.
3. We use the Compare function, and then change the locations if carry flag is not set.

12
• RESULTS:

– Input:

Address value
C500H 00H
C501H 01H
C502H 02H
C503H 03H
C504H 04H
C505H 05H
C506H 06H
C507H 07H
C508H 08H
C509H 09H

– Output:

Address value
C500H 09H
C501H 08H
C502H 07H
C503H 06H
C504H 05H
C505H 04H
C506H 03H
C507H 02H
C508H 01H
C509H 00H

• CONCLUSION:
The above program successfully sorts the list of numbers in de-
scending order.

13
EXPERIMENT-6

• AIM: To write an 8085 program to count number of data bytes contining postive,
negative, and zero from a set of data bytes stored from C100H to C109H.

• MNEMONICS AND HEX CODE:

Lower order address Higher order


Starting Address Instruction Hex Code
Byte/8 bit data address Byte
D000 H LXI H,C100 H 21 00 C1
D003 H MOV B,0AH 06 0A
D005 H: loop: MOV A,M 7E
D006 H: CPI 00H FE 00
D008 H CZ zero CC 25 D0
D00B H RAL 1F
D00C H CC odd DC 21 D0
D00F H: CNC even D4 23 D0
D012 H: INX H 23
D013 H: DCR B D5
D014 H: JNZ loop C2 05 D0
D017 H: MOV A,E 7B
DO18 H: SUB C 91
DO19 H: MOV E,A 5F
DO1A H: INX H 23
D01B H: MOV M,D 72
DO1C H: INX H 23
DO1D H: MOV M,E 73
DO1E H: INX H 23
DO1F H: MOV M,C 71
DO20 H: RST-1 CF
DO21 H: negative: INR D 14
D022 H: RET C9
DO23 H: positive: INR E 1C
D024 H: RET C9
DO25 H: zero: INR C 0C
D026 H: RET C9

14
• COMMENTS:

1. Register B is used as a counter, and is initialized with the value OAH.


2. We use different sub routines for the three cases, and then increment the registers
D, E and C if and when the conditions are met.

• RESULTS:

– Input:

Address value
C100H 00H
C101H A8H
C102H 01H
C103h 02H
C104H 03H
C105H 04H
C106H A7H
C107H 08H
C108H 05H
C109H 09H

– Output:

Address value
C10BH 02H
C10CH 07H
C10DH 01H

• CONCLUSION:
The above program counts the number of positive, negative, and
zeros in the given list of data points.

15
EXPERIMENT-7

• AIM: To write an 8085 program to count the number of odd, even, and zeros from the
given list of data starting from memory location C100H to C109H

• MNEMONICS AND HEX CODE:

Lower order address Higher order


Starting Address Instruction Hex Code
Byte/8 bit data address Byte
D000 H LXI H,C100 H 21 00 C1
D003 H MOV B,0AH 06 0A
D005 H: loop: MOV A,M 7E
D006 H: CPI 00H FE 00
D008 H CZ zero CC 25 D0
D00B H RAR 1F
D00C H CC odd DC 21 D0
D00F H: CNC even D4 23 D0
D012 H: INX H 23
D013 H: DCR B D5
D014 H: JNZ loop C2 05 D0
D017 H: MOV A,E 7B
DO18 H: SUB C 91
DO19 H: MOV E,A 5F
DO1A H: INX H 23
D01B H: MOV M,D 72
DO1C H: INX H 23
DO1D H: MOV M,E 73
DO1E H: INX H 23
DO1F H: MOV M,C 71
DO20 H: RST-1 CF
DO21 H: odd: INR D 14
D022 H: RET C9
DO23 H: even: INR E 1C
D024 H: RET C9
DO25 H: zero: INR C 0C
D026 H: RET C9

16
• COMMENTS:

1. The least significant bit is sent into carry by rotating right.


2. If number is even, the number of evens is incremented, else the number of odds is
incremented.
3. The number of odds is stored in memory location C10BH, the number of evens in
C10CH and the number of zeros in C10DH.

• RESULTS:

– Input:

Address value
C100H 00H
C101H 01H
C102H 02H
C103h 03H
C104H 04H
C105H 05H
C106H 06H
C107H 07H
C108H 08H
C109H 09H

– Output:

Address value
C10BH 05H
C10CH 04H
C10DH 01H

• CONCLUSION:
The above program is able to count the number of odd, even and
zero data bytes from a given list of data.

17
EXPERIMENT-8

• AIM: To write an 8085 program to convert a BCD number stored at memory location
C500H to a hexadecimal number, and to store it in memory location C501H.

• MNEMONICS AND HEX CODE:

Lower order address Higher order


Starting Address Instruction Hex Code
Byte/8 bit data address Byte
D000 H MVI C,09H 0E 09
D002 H LXI H,C500H 21 00 C5
D005 H: MOV A,M 7E
D006 H: ANI 0FH E6 0F
D008 H MOV B,A 47
D009 H MOV A,M FE
D00A H ANI F0h E6 F0
D00C H: RAR 1F
D00D H: RAR 1F
D00E H: RAR 1F
D00F H: RAR 1F
D010 H: MOV D,A 57
D011 H: addl: ADD D B2
D012 H: DCR C 0D
D013 H: JNZ addl C2 11 D0
DO16 H: ADD B 80
DO17 H: INX H 23
DO18 H: MOV M,A 77
DO19 H: RST-1 CF

• COMMENTS:

1. We add the left most nibble ten times and the right most nibble to the result in
accumulator to obtain the hexadecimal equivalent.

18
• RESULTS:

– Input:

Address value
C500H 35

– Output:

Address value
C501H 53H

• CONCLUSION:
The above program is able to convert data from BCD to Hex.

19
EXPERIMENT-9

• AIM: To write an 8085 program to convert a Hexadecimal number stored at memory


location C500H to a BCD number, and to store it in memory location C501H.

• MNEMONICS AND HEX CODE:

Lower order address Higher order


Starting Address Instruction Hex Code
Byte/8 bit data address Byte
D000 H MVI C,00H 0E 00
D002 H LXI H,C500H 21 00 C5
D005 H: MVI B,0AH 06 0A
D007 H: MOV A,B 78
D008 H CPI M BE
D009 H CNC hex D4 1D D0
D00C H MOV A,M 7E
D00D H: subloop: SUB B 90
D00E H: INR C 0C
D00F H: CMP B B8
D010 H: JNZ subloop D2 0D D0
D013 H: MOV D,A 57
D014 H: MOV A,C 79
D015 H: RLC 07
D016 H: RLC 07
D017 H: RLC 07
D018 H: RLC 07
D019 H: ADD D 82
DO1A H: INX H 23
DO1B H: MOV M,A 77
DO1C H: RST-1 CF
D01D H: hex: MOV E,M 5E
D01E H: INX H 23
D01F H: MOV M,E 73
D020 H: RET C9

20
• COMMENTS:

1. We subtract 10 from the accumulator until the accumulator holds data less than 10.
2. The number of times this subtraction is carried out is recorded in the register C and
ultimately contains the left nibble of BCD number.
3. The result of the subtraction in accumulator (A) is the right nibble of the desired
BCD number.

• RESULTS:

– Input:

Address value
C500H 53H

– Output:

Address value
C501H 35

• CONCLUSION:
The above program can be used to convert Hex codes into BCD
codes.

21
EXPERIMENT-10

• AIM: Write an 8085 assembly language program to count the number of vowels (capital
and small) in a given string.
a=61, e=65, i=69, o=6F, u=75, A=41, E=45, I=49, O=4F, U=55.

• MNEMONICS AND HEX CODE:

Lower order address Higher order


Starting Address Instruction Hex Code
Byte/8 bit data address Byte
D000 H: LXI H,C100 H 21 00 C1
D003 H: MOV B,L 45
D004 H: MOV A,M 7E
D005 H: Back: RLC 07
D006 H: JC Last DA 2A D0
D009 H: RLC 07
D00A H: JC Last DA 2A D0
D00D H: RLC 07
D00E H: RLC 07
D00F H: JC Loop DA 24 D0
D012 H: MOV A,M 7E
D013 H: ANI 0F H E6 0F
D015 H: CPI 01 H FE 01
D017 H: JZ Skip CA 2C D0
D01A H: CPI 09 H FE 09
D01C H: JZ Skip CA 2C D0
D01F H: Next: CPI 0F H FE 0F
D021 H: JZ Skip CA 2C D0
D024 H: Loop: MOV A,M 7E
D025 H: ANI 0F H E6 0F
D027 H: CPI 05 H FE 05
D029 H: JNZ Last C2 2D D0
D02C H: INR B 04
D02D H: INX H 23
D02E H: MOV A,M 7E
D02F H: SUI 00 H D6 00
D031 H: JNZ Back C2 05 D0
D034 H: INX H 23
D034 H: MOV M,B 70
D036 H: RST-1 CF

22
• COMMENTS:

1. CPI is used to compare the value of the accumulator with the immediate number.
2. SUI subtracts the immediate number for the value of accumulator.
3. ANI 0FH used for masking.

• RESULTS:

– Input:

Address value
C100 H 41
C101 H 45
C102 H 65
C103 H 55
C104 H 4F
C105 H 00

– Output:

Address value
C106 H 05H

• CONCLUSION:
The above program is used to check the number of vowels in a
string. It uses the hex equivalent of ASCII codes, and checks for the appropriate code.

23
EXPERIMENT-11

• AIM: To write an 8085 program to interface 8255 with the 8085 chip, and to turn on
the LEDs.

• MNEMONICS AND HEX CODE:

Lower order address Higher order


Starting Address Instruction Hex Code
Byte/8 bit data address Byte
D000 H MVI A,80h 3E 80
D002 H OUT 13 D3 13
D004 H: LXI B,FFFFH 7E FF FF
D007 H: LXI D,0108H 11 08 01
D00A H MOV A,D 7A 0A
D00C H OUT 10/11/12 D3 10/11/12
D00E H RLC 07
D00F H: MOV D,A 57
D010 H: NOP 00
D011 H: NOP 00
D012 H: NOP 00
D013 H: MOV A,B 75
D014 H: MOV A,C 79
D015 H: ORA C B1
D016 H: JNZ loop C2 10 D0
D019 H: DCR E 1D
D01A H: JNZ back C2 0A D0
DO1D H: RST-1 CF

• COMMENTS:

1. Register E is acting as a counter, and is initialized with 08H, since there are only 8
pins to each port.
2. Since we, know that the LED’s are interfaced in such a way that each nibble gets
a diode, we can initialize D as 01H and keep multiplying by 2, to get each port
accessed.

24
• RESULTS:

– Output:

Input Hex Port A (10) Port B (11) Port C (12)


01 L10 L1 L14
02 L9 L3 L12
04 L7 L20 L11
08 L6 L19 L13
10 L8 L17 -
20 L5 L16 -
40 L4 L18 -
80 L2 L15 -

• CONCLUSION:
We have interfaced the 8255 chip with the 8085 microprocessor,
and we can see that out of the 24 pins, 20 are used, while 4 are not.

25
EXPERIMENT-12

• AIM: To write an 8085 program to make a running LED pattern with a time gap of
0.77 seconds.

• MNEMONICS AND HEX CODE:

Lower order address Higher order


Starting Address Instruction Hex Code
Byte/8 bit data address Byte
D000 H MVI A,80 H 3E 80
D002 H OUT 13 D3
D004 H: MVI A,21 H 3E 21
D006 H: OUT 10 D3
D008 H MVI A,84 H 3E 84
D00A H OUT 11 D3
D00C H CALL delay CD 00 E0
D010 H: MVI A,42 H 3E 42
D012 H: OUT 10 D3 08
D014 H: MVI A,08 H 3E
D016 H: OUT 11 D3 01
D018 H: MVI A,01 H 3E 01
D01A H: OUT 12 D3
D01C H: CALL delay CD 00 E0
D020 H: MVI A,9C H 3E 9C D
D022 H: OUT 10 D3
D024 H: MVI A,73 H 3E 73
D026 H: OUT 11 D3
D028 H: MVI A,0E H 3E 0E
D02A H: OUT 12 D3
D02C H: RST-1 CF
E000 H: delay: LXI B,FFFF 01 FF FF
E001 H: loop: NOP 00
E002 H: NOP 00
E003 H: NOP 00
E004 H: DCX B 0B
E005 H: MOV A,B 78
E006 H: ORA C B1
E007 H: JNZ loop C2 03 E0
E008 H: RET C9

26
• COMMENTS:

1. Time delay = No. of T states Outside loop + ( Count * No. of T state inside loop)
- 3T
= (14 *0.33 microsec) + (FFFF *36*0.33 µs+3*0.33 µs)
Time delay = 0.77 sec

• RESULTS:

In the result we see the developed pattern of running LEDs with a time lapse of 0.77
seconds.

• CONCLUSION:
We have written a program to generate a pattern of lights with a
fixed delay.

27

S-ar putea să vă placă și