Anda di halaman 1dari 72

Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 1

Ex. No.: 1
Date : 05.07.2011
ADDITION OF TWO 8-BIT NUMBERS
Aim:
To perIorm the Addition oI two 8-bit numbers using 8085 microprocessor.
Algorithm:
1. oad the augend in accumulator.
2. oad the addend in register B.
3. Add the two 8-bit data.
4. Store the output sum in speciIied memory location.
Program:
DA 8600
MOV B, A
DA 8601
ADD B
STA 8602
HT
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 2


Execution Table:
Memory
Address
Hex
Code
Label Mnemonics Comments
8000 3A

DA 8600 oad accumulator with the contents oI
memory location 8600 8001 00
8002 86
8003 47 MOV B, A Move the contents to B register
8004 3A

DA 8601 oad accumulator with the contents oI
memory location 8601 8005 01
8006 86
8007 80 ADD B Add the two 8-bit data
8008 32

STA 8602 Store the result in memory location
8602 8009 02
800A 86
800B 76 HT Terminate program execution




Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 3


Output Table:
Input Output
Memory Address Data Memory Address Data
8600 05 8600 05
8601 06 8601 06
8602 00 8602 0B








Result:
Thus, the addition oI two 8-bit numbers is perIormed using 8085 microprocessor.

Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 4

Ex. No.: 2
Date : 05.07.2011
SUBTRACTION OF TWO 8-BIT NUMBERS
Aim:
To perIorm the Subtraction oI two 8-bit numbers using 8085 microprocessor.
Algorithm:
1. oad the subtrahend in accumulator.
2. oad the minuend in register B.
3. Subtract the two 8-bit data.
4. Store the output diIIerence in speciIied memory location.
Program:
DA 8600
MOV B, A
DA 8601
SUB B
STA 8602
HT
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 3


Execution Table:
Memory
Address
Hex
Code
Label Mnemonics Comments
8000 3A

DA 8600 oad accumulator with the contents oI
memory location 8600 8001 00
8002 86
8003 47 MOV B, A Move the contents to B register
8004 3A

DA 8601 oad accumulator with the contents oI
memory location 8601 8005 01
8006 86
8007 90 SUB B Subtract the two 8-bit data
8008 32

STA 8602 Store the result in memory location
8602 8009 02
800A 86
800B 76 HT Terminate program execution




Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 6


Output Table:
Input Output
Memory Address Data Memory Address Data
8600 06 8600 06
8601 05 8601 05
8602 00 8602 01







Result:
Thus, the subtraction oI two 8-bit numbers is perIormed using 8085 microprocessor.



Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 7

Ex. No.: 3
Date : 12.07.2011
DIVISION OF TWO 8-BIT NUMBERS
Aim:
To perIorm the Division oI two 8-bit numbers using 8085 microprocessor.
Algorithm:
1. Set the counter register C as zero.
2. oad the divisor and dividend values in the respective registers.
3. Subtract one value Irom the other and increment the counter.
4. Repeat the subtraction till the result becomes zero or a carry is generated.
5. For each subtraction the counter is incremented.
6. The Iinal value in the counter gives the result and the value in the A register gives remainder.
7. Store the results in speciIied memory locations.




Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 8


Program:
H, 8200
MOV B, M
N H
MOV A, M
MV C, 00
OOP 2: CMP B
JC OOP 1
SUB B
NR C
JMP OOP 2
OOP 1: STA 8202
MOV A, C
STA 8203
HT

Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 9

Execution Table:
Memory
Address
Hex
code
Label Mnemonics Comments
8000 21 H, 8200 oads given 16-bit data in the H register pair
8001 00
8002 82
8003 46 MOV B, M Copies the content oI M into B register
8004 23 N H ncrements the H pair by one
8005 7E MOV A, M Copies the contents oI M into Accumulator
8006 0E MV C, 00 oads 00H in C register
8007 00
8008 B8 OOP 2 CMP B Compares the content oI B with Accumulator
8009 DA JC OOP 1 Jump to OOP 1 iI carry is generated
800A 11
800B 80
800C 90 SUB B Subtracts the content oI B Irom Accumulator
800D 0C NR C ncrements C register by one
800E C3 JMP OOP 2 Jump to OOP 2
800F 08
8010 80
8011 32 OOP 1 STA 8202 Store the content oI Accumulator in the memory
8012 02
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 10

8013 82
8014 79 MOV A, C Copies the content oI C into A
8015 32 STA 8203 Store the content oI Accumulator in the memory
8016 03
8017 82
8018 76 HT Finishes the execution oI the program

Output Table:
Input Output
Memory address Data Memory address Data
8200 03H 8202 00H
8201 12H 8203 04H



Result:
Thus the assembly language program Ior the division Ior two 8-bit numbers using 8085
microprocessor is perIormed.


Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 11

Ex. No.: 4
Date : 12.07.2011
MULTIPLICATION OF TWO 8-BIT NUMBERS

Aim:
To perIorm the multiplication oI two 8-bit numbers using 8085 microprocessor.

Algorithm:
1. Get the input values in B register and accumulator.
2. Use one value as counter and add the other value with itselI.
3. Decrement the counter and repeat the addition process till the counter becomes zero.
4. I carry is generated, increment the carry register.
5. Store the results in speciIied memory locations.




Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 12


Program:
DA 8600
MOV B, A
DA 8601
MOV D, A
RA A
OOP2: ADD B
JNC OOP1
NR C
OOP1: DCR D
JNZ OOP2
STA 8602
MOV A, C
STA 8603
HT

Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 13

Execution Table:
Memory
Address
Hex
code
Label Mnemonics Comments
8000 3A DA 8600 oads Accumulator with the content oI memory
location speciIied 8001 00
8002 86
8003 47 MOV B, A Copies the content oI Accumulator into B
8004 3A DA 8601 oads Accumulator with the content oI memory
location speciIied 8005 01
8006 86
8007 57 MOV D, A Copies the content oI Accumulator into D
8008 AF RA A Clears the Accumulator
8009 80 OOP2 ADD B Adds the content oI B with Accumulator
800A D2 JNC OOP 1 Jump to OOP 1 iI no carry is generated
800B 0E
800C 80
800D 0C NR C ncrements the content oI C by one
800E 15 OOP 1 DCR D Decrements the content oI D one
800F C2 JNZ OOP 2 Jump to OOP 2 iI zero Ilag is reset
8010 09
8011 80
8012 32 STA 8603 Store the content oI Accumulator in the memory
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 14

8013 03 location
8014 86
8015 79 MOV A, C Copies the content oI C into Accumulator
8016 32 STA 8602 Store the content oI Accumulator in the memory
location 8017 02
8018 86
8019 76 HT Finishes the execution oI the program


Output table:
Input Output
Memory address Data Memory address Data
8600 06H 8602 00H
8601 03H 8603 12H


Result:
Thus the assembly language program Ior the multiplication Ior two 8-bit numbers using 8085
microprocessor is perIormed.

Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 13

Ex. No.: 5
Date : 19.07.2011
DIVISION OF TWO 16-BIT NUMBERS
Aim :
To perIorm 16 bit division using 8085 microprocessor.
Algorithm :
1. oad the dividend in the H register.
2. oad the divisor in any 8-bit register.
3. The divisor is subtracted Irom the dividend .
4. Each time this subtraction is done, a register indicating quotient is incremented.
5. The results are stored in the memory.
Program :
HD 8200
DA 8202
MOV C, A
D, 0000
OOP 1: MOV A,
SUB C
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 16

MOV , A
JNC OOP 2
DCR H
OOP 2: N D
MOV A, H
CP 00
JNZ OOP 1
MOV A,
CMP C
JNC OOP 1
MOV A,
CMP C
JNC OOP 1
SHD 8302
CHG
SHD 8300
HT

Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 17

Execution Table:
Memory
Address
Hex
Code
Label Mnemonics Comments
8000 2A
HD 8200 oad the contents oI memory locations 8200 and 8201
into H register pair
8001 00
8002 82
8003 3A
DA 8202 oad the contents oI memory location 8202 into the
accumulator
8004 02
8005 82
8006 4F MOV C, A Copy the contents oI accumulator to register C
8007 11 D,0000 nitialize DE register pair
8008 00
8009 00
800A 7D OOP1 MOV A, Move the contents oI register to the accumulator
800B 91
SUB C Subtract contents oI C register with the data in the
accumulator
800C 6F MOV , A Copy the contents oI accumulator to register
800D D2
JNC
OOP2
I carry Ilag is not set, jump to loop 2
800E 11
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 18

800F 80
8010 25 DCR H Decrement H register
8011 13 OOP2 N D ncrement the data in H register pair
8012 7C MOV A, H Copy the contents oI H register to the accumulator
8013 FE CP 00 Compare 00 with data in the accumulator
8014 00
8015 C2
JNZ
OOP1
I zero Ilag is not set, jump to loop 1
8016 0A
8017 80
8018 7D MOV A, Copy the contents oI register to the accumulator
8019 B9
CMP C Compare the data in the C register with that oI the
accumulator
801A D2
JNC
OOP1
I carry Ilag is not set, jump to loop 1
801B 0A
801C 80
801D 22
SHD 8302 Store the contents oI H register pair in memory
locations 8302 and 8303
801E 02
801F 83
8020 EB CHG Exchange the contents oI DE and H register pair
8021 22 SHD 8300 Store the contents oI H register pair in memory
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 19


Output Table:
Input Output
Memory Address Data Memory Address Data
8200 32 8302 08
8201 32 8303 08
8202 04 8300 00
8301 00




Result:
Thus the assembly anguage Program to perIorm 16 bit division is perIormed using 8085
Microprocessor.
locations 8300 and 8301
8022 00
8023 83
8024 76 HT Terminate program execution
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 20


Ex. No.: 6
Date : 26.07.2011
MULTIPLICATION OF TWO 16-BIT NUMBERS
Aim:
To perIorm the multiplication oI two 16- bit numbers using 8085 microprocessor.
Algorithm:
1. Get the required 16 bit numbers in two suitable register pairs.
2. Clear the H register pair.
3. Make one register as the counter and add the other number with itselI using the DAD
instruction.
4. AIter each addition the counter is decremented and is checked Ior zero condition.
5. I carry is generated aIter add instruction another register pair should be incremented by one.
6. When the counter becomes zero the results oI the addition are stored.
7. Execute the program to display the results.



Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 21


Program:
D, 0000
H, 0000
SP, 8600
MV B, 00
MV C, 03
OC 1: DAD SP
JC OC 2
OC 3: DC B
MOV A, C
ORA B
JNZ OC 1
HT
OC 2: N D
JMP OC 3

Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 22

Execution Table:
Memory
Address
Hex
code
Label Mnemonics Comments

8000 11 D, 0000 Set the contents oI DE register pair equal to zero
8001 00
8002 00
8003 21 H, 0000 Set the contents oI H register pair equal to zero
8004 00
8005 00
8006 31 SP, 8600 Set the contents oI Stack pointer equal to 8600
8007 0
8008 86
8009 06 MV B, 00 Set the contents oI B register equal to zero
800A 00
800B 0E MV C, 03 Set the contents oI C register equal to 03
800C 03
800D 39 OC 1 DAD SP To perIorm 16 bit addition.
800E DA JC OC 2 Jump to OC 2 iI carry is generated
800F 18
8010 80
8011 0B OC 3 DC B Decrement the contents oI BC register pair
8012 79 MOV A, C Copy the contents oI C to A
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 23

8013 B0 ORA B OR the contents oI B with A
8014 C2 JNZ OC 1 Jump to OC 1 iI zero Ilag is not set
8015 0D
8016 80
8017 76 HT Halt the program
8018 13 OC 2 N D ncrement the contents oI DE register pair
8019 C3 JMP OC 3 Jump to OC 3
801A 11
801B 80

Output table:
Input Output
Memory address Data Memory address Data
8600 06H 8602 00H
8601 03H 8603 12H


Result:
Thus the assembly language program Ior the multiplication oI two 16-bit numbers using 8085
microprocessor is perIormed.

Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 24

Ex. No.: 7
Date : 02.08.2011
SORTING AN ARRAY IN ASCENDING ORDER
Aim:
To arrange the given array oI 8-bit numbers in ascending order using 8085 microprocessor.
Algorithm:
1. Compare the Iirst two 8-bit numbers in the memory.
2. nterchange them iI the value in Iirst memory location is greater than the value in second
memory location. Otherwise, don`t interchange.
3. Compare the contents oI second and third memory location and, interchange iI needed.
4. Continue this process till the last two numbers are compared and interchanged.
5. Repeat the above steps n-1 times.
Program:
MV C, 04
OC3: MOV D, C
H, 8600
OC1: DCR D
JZ OC2
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 23


MOV A, M
N H
CMP M
JC OC1
` MOV B, M
MOV M, A
DC H
MOV M, B
N H
JMP OC1
OC2: DCR C
JNZ OC3
HT



Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 26

Execution Table:
Memory
Address
Hex
Code
Label Mnemonics Comments
8000 0E

MV C, 04

nitialize the counter 1
8001 04
8002 51 OC3 MOV D, C nitialize the counter 2
8003 21


H, 8600


nitialize starting memory location


8004 00
8005 86
8006 15 OC1 DCR D Decrement counter 2
8007 CA


JZ OC2


Jump to OC2 iI zero Ilag is set


8008 18
8009 80
800A 7E MOV A, M Move the contents oI M to A
800B 23 N H ncrement memory pointer
800C BE CMP M Compare the contents oI M with A
800D DA


JC OC1


Jump to OC1 iI carry Ilag is set


800E 06
800F 80
8010 46 MOV B, M Move the contents oI M to B
8011 77 MOV M, A Move the contents oI A to M
8012 2B DC H Decrement memory pointer
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 27



Output Table:
Input Output
Memory Address Data Memory Address Data
8600 1A 8600 18
8601 18 8601 1A
8602 1C 8602 1B
8603 1B 8603 1C

Result:
Thus, sorting an array oI 8-bit numbers in ascending order is perIormed using 8085 microprocessor.
8013 70 MOV M, B Copies the contents oI B to M
8014 23 N H ncrement memory pointer
8015 C3


JMP OC1


Jump to OC1


8016 06
8017 80
8018 0D OC2 DCR C Decrement counter 1
8019 C2


JNZ OC3


Jump to OC3 iI zero Ilag is reset


801A 02
801B 80
801C 76 HT Terminate program execution
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 28

Ex. No.: 8
Date : 02.08.2011
SORTING AN ARRAY IN DESCENDING ORDER
Aim:
To arrange the given array oI 8-bit numbers in descending order using 8085 microprocessor.
Algorithm:
1. Compare the Iirst two 8-bit numbers in the memory.
2. nterchange them iI the value in Iirst memory location is smaller than the value in second
memory location. Otherwise, don`t interchange.
3. Compare the contents oI second and third memory location and, interchange iI needed.
4. Continue this process till the last two numbers are compared and interchanged.
5. Repeat the above steps n-1 times.
Program:
MV C, 04
OC3: MOV D, C
H, 8600
OC1: DCR D
JZ OC2
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 29


MOV A, M
N H
CMP M
JNC OC1
` MOV B, M
MOV M, A
DC H
MOV M, B
N H
JMP OC1
OC2: DCR C
JNZ OC3
HT



Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 30

Execution Table:
Memory
Address
Hex
Code
Label Mnemonics Comments
8000 0E

MV C, 04

nitialize the counter 1
8001 04
8002 51 OC3 MOV D, C nitialize the counter 2
8003 21


H, 8600


nitialize starting memory location


8004 00
8005 86
8006 15 OC1 DCR D Decrement counter 2
8007 CA


JZ OC2


Jump to OC2 iI zero Ilag is set


8008 18
8009 80
800A 7E MOV A, M Copies the contents oI M to A
800B 23 N H ncrement memory pointer
800C BE CMP M Compare the contents oI M with A
800D D2


JNC OC1


Jump to OC1 iI carry Ilag is set


800E 06
800F 80
8010 46 MOV B, M Copies the contents oI M to B
8011 77 MOV M, A Copies the contents oI A to M
8012 2B DC H Decrement memory pointer
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 31

8013 70 MOV M, B Copies the contents oI B to M
8014 23 N H ncrement memory pointer
8015 C3 JMP OC1 Jump to OC1
8016 06
8017 80
8018 0D OC2 DCR C Decrement counter 1
8019 C2
JNZ OC3


Jump to OC3 iI zero Ilag is reset


801A 02
801B 80
801C 76 HT Terminate program execution

Output Table:
Input Output
Memory Address Data Memory Address Data
8600 1A 8600 1C
8601 18 8601 1B
8602 1C 8602 1A
8603 1B 8603 18

Result:
Thus, sorting an array oI 8-bit numbers in descending order is perIormed using 8085 microprocessor
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 32

Ex. No.: 9
Date : 09.08.2011
LARGEST ELEMENT IN AN ARRAY
Aim:
To Iind the largest element in an array using 8085 Microprocessor.
Algorithm:
1. Set the content oI C-register as the number oI array elements.
2. Move the 1
st
element Irom memory into the accumulator.
3. Decrement the C-register
4. I the content oI C-register is zero, then got end oI program else continue.
5. Move the next element into the H-register.
6. Compare the element in Accumulator with element in H-register.
7. I accumulator content is smaller than H content, copy the H-register to accumulator and go to
step 3.
8. I accumulator content is larger, go to step 3.
9. Do the above procedure till content oI C-register is zero.
10.Store the accumulator content in memory.


Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 33


Program:
MV C, 05
H, 8500
MOV A, M
OOP1: DCR C
JZ OOP2
N H
CMP M
JNC OOP1
MOV A, M
JMP OOP1
OOP2: STA 8500
HT



Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 34

Execution table:
Memory
Address
Hex
Code
Label Mnemonics Comments
8000 0E MV C,05 Set the content oI C-register equal to 05
8001 05
8002 21 H,8500 oad the content oI address 8500 in register
pair H 8002 00
8003 85
8004 7E MOV A,M Move the content oI H8-bit data) into the
Accumulator
8005 0D OOP 1 DCR C Decrement the C-register
8006 C2 JZ OOP2 I zero Ilag is set ,jump to loop2
8007 12
8008 80
8009 23 N H Contents oI H-register is incremented by one
800A BE CMP M Compare the Accumulator content with
MH) register
800B D2 JNC OOP1 I no carry is set ,jump to loop1
800C 05
800D 80
800E 7E MOV A,M Move the content oI H8-bit data) into the
Accumulator
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 33



Output Table:
Input Output
Memory location Data Memory location Data
8500 07 8500 09
8501 06 8501 07
8502 09 8502 06
8503 05 8503 05
8504 03 8504 03

Result:
Thus the Assembly language program to Iind the largest element in an array is perIormed using
8085 Microprocessor.

800F C3 JMP OOP1 Jump to loop1
8010 05
8011 80
8012 32 OOP 2 STA 8500 Store the Accumulator content in 8500
memory location 8013 00
8014 85
8015 76 HT Halt the program
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 36

Ex. No.: 10
Date : 09.08.2011
SMALLEST ELEMENT IN AN ARRAY
Aim:
To Iind the smallest element in an array using 8085 Microprocessor.
Algorithm:
1. Set the content oI C-register as the number oI array elements.
2. Move the 1
st
element Irom memory into the accumulator.
3. Decrement the C-register
4. I the C-register is zero, then go to end oI program else continue .
5. Move the next element into the H-register.
6. Compare the element in Accumulator with element in H-register.
7. I the accumulator content is larger than H register content, copy the H-register to accumulator
and go to step 3.
8. I A content is smaller, go to step 3.
9. Do the above procedure till content oI C-register is zero.
10.Store the accumulator content in memory.


Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 37


Program:
MV C, 05
H, 8500
MOV A, M
OOP1: DCR C
JZ OOP2
N H
CMP M
JC OOP1
MOV A, M
JMP OOP1
OOP2: STA 8500
HT



Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 38

Execution table:
Memory
Address
Hex
Code
Label Mnemonics Comments
8000 0E MV C,05 Set the content oI C-register equal to 05
8001 05
8002 21 H,8500 oad the content oI address 8500 in register pair
H 8002 00
8003 85
8004 7E MOV A,M Move the content oI H8-bit data) into the
Accumulator
8005 0D OOP 1 DCR C Decrement the C-register
8006 C2 JZ OOP2 I zero Ilag is set ,jump to loop2
8007 12
8008 80
8009 23 N H Contents oI H-register is incremented by one
800A BE CMP M Compare the Accumulator content with MH)
register
800B DA JC OOP1 I carry is set ,jump to loop1
800C 05
800D 80
800E 7E MOV A,M Move the content oI H8-bit data) into the
Accumulator
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 39

800F C3 JMP OOP1 Jump to loop1
8010 05
8011 80
8012 32 OOP 2 STA 8500 Store the Accumulator content in 8500 memory
location 8013 00
8014 85
8015 76 HT Halt the program

Output Table:
Input Output
Memory location Data Memory location Data
8500 07 8500 03
8501 06 8501 07
8502 09 8502 06
8503 05 8503 09
8504 03 8504 05

Result:
Thus the Assembly language program to Iind the smallest element in an array is perIormed
using 8085 Microprocessor.

Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 40

Ex. No.: 11
Date : 16.08.2011
FIBONACCI SERIES
Aim:
To generate the Fibonacci series using 8085 Microprocessor.
Algorithm:
1. Get the number oI terms in Accumulator.
2. Store the Iirst and second number in consequent memory locations.
3. Add the two numbers and store it in next location .
4. Decrease the content oI accumulator by 1.
5. Add the last and previous number and store it in next location.
6. Decrease the accumulator content by 1.
7. Continue the steps till the accumulator content reaches 0.
8. End oI program.





Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 41

Program:
H, 8650
MV C, 0A
MV M, 00
DCR C
N H
MV M, 01
DCR C
MOV A, M
OOP1: DC H
ADD M
N H
N H
MOV M, A
DCR C
JNZ OOP1
HT
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 42

Execution Table:
Memory
Address
Hex
Code
Label Mnemonics Comments
8000 21 H, 8650 M points to the memory location 8650
8001 50
8002 86
8003 0E MV C, 0A Move the immediate data 0A to register C
8004 0A
8005 36 MV M, 00 Clearing the contents memory pointer M
8006 00
8007 0D DCR C Decrement the content oI C-register by 1
8008 23 N H ncrement the memory pointer by 1
8009 36 MV M, 01 Move the immediate value 01 to the location
pointed by M 800A 01
800B 0D DCR C Decrement the content oI C-register by 1
800C 7E MOV A, M Move the content oI location pointed by M to
Accumulator
800D 2B OOP1 DC H Decrement the memory pointer by 1
800E 86 ADD M Add the content oI location pointed by M to
Accumulator
800F 23 N H ncrement the memory pointer by 1
8010 23 N H ncrement the memory pointer by 1
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 43

8011 77 MOV M, A Move the content oI Accumulator to location
pointed by M
8012 0D DCR C Decrement the content oI C-register by 1
8013 C2 JNZ 800D Jump to location 800D iI content oI C-register is
00 8014 0D
8015 80
8016 76 HT End oI the program

Output:
Memory Location Data
8650 00
8651 01
8652 01
8653 02
8654 03
8655 05
8656 08
8657 0D
8658 15
Result:
Thus the assembly language program to generate the Fibonacci series is done using 8085
microprocessor.
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 44

Ex. No.: 12
Date : 16.08.2011
SUM OF N-NUMBERS IN AN ARRAY
Aim:
To Iind the sum oI N elements in an array using 8085 micro-processor.
Algorithm:
1. Get the number oI elements N Ior which sum is to be calculated.
2. Add Iirst two numbers and store it in accumulator.
3. Add the next number with accumulator.
4. Decrement N Ior every addition.
5. Continue above steps till N reaches 0.
6. End oI program.
Program:
DA 8200
MOV C, A
H, 8210
MOV A, M
DCR C
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 43

OOP2: N H
ADD M
JNC OOP1
NR D
OOP1: DCR C
JNZ OOP2
STA 8201
MOV A,D
STA 8202
HT
Execution Table:
Memory
Address
Hex
Code
Label Mnemonics Comments
8000 3A DA 8200 oad the accumulator with a value Irom memory
location 8200
8001 00
8002 82
8003 4F MOV C, A Copy the contents oI accumulator to C-register
8004 21 H, 8210 t stores the value oI 8210 in H register pair
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 46

8005 10
8006 82
8007 7E MOV A, M Copy contents oI address) pointed by H to
accumulator
8008 0D DCR C Decrement the content oI C-register by 1
8009 23 OOP2 N H ncrement the content oI H pair by 1
800A 86 ADD M Add the content oI accumulator with content
pointed by H pair
800B D2 JNC OOP1 Jump to OOP1 iI no carry is generated.
800C 14 NR D ncrement the content oI D-register by 1
800D 0D OOP1 DCR C Decrement the content oI C-register by 1
800E C2 JNZ OOP2 Jump to OOP 2 iI content oI C is non-zero
800F 09
8010 80
8011 32 STA 8201 Store the content oI accumulator to memory
location 8201
8012 01
8013 82
8014 7A MOV A, D Copy the content oI D-register to accumulator
8015 32 STA 8202 Store the accumulator content to memory 8202
8016 02
8017 82
8018 76 HT Halt the program
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 47


Output:
Input Output
Memory Address Data Memory Address Data
8200 05 8201 27
8210 04 8202 00
8211 03
8212 02
8213 0F
8214 0F




Result:
Thus the assembly language program to Iind sum oI N-elements in an array is done using 8085
microprocessor.


Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 48

Ex. No.:13
Date : 23.08.2011
CODE CONVERSION
Aim:
To convert a) the given BCD number into its equivalent Hex number and
b) Irom the given Hex number into its equivalent BCD number.
Algorithm:
a). BCD to Hex:
1. Get the 8-bit packed BCD number.
2. Separate it into two 4-bit unpacked BCD digits.
3. Convert each digit into its binary value according to its positions.
4. Add both binary numbers to obtain the Hex equivalent oI the BCD number.
b). Hex to BCD:
1. Get the Hex number.
2. Divide it by 100 decimal) to get the quotient which gives the most signiIicant digit,
digit 2 oI the BCD number.
3. Divide the remainder by 10 decimal) to get the quotient which gives digit 1 oI the
BCD number and the remainder gives digit 0 oI the BCD number.
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 49


Program:
a). BCD to Hex:
DA 8000
MOV B, A
AN 0F
MOV C, A
MOV A, B
AN F0
RRC
RRC
RRC
RRC
MOV B, A
RA A
MV D, 0A
OC1: ADD D
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 30

DCR B
JNZ OC1
ADD C
STA 8050
HT

b). Hex to BCD:
SP, 8FFF
DA 8000
CA OC
HT
OC: MV B, 64
MV C, 0A
MV D, 00
MV E, 00
OC1: CMP B
JC OC2
SUB B
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 31

NR E
JMP OC1
OC2: CMP C
JC OC3
SUB C
NR D
JMP OC2
OC3: STA 8100
MOV A, D
STA 8101
MOV A, E
STA 8102
RET





Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 32

Execution Table:
a). BCD to Hex:
Memory
address
Hex
Code
Label Mnemonics Comments
8100 3A DA 8000 Get the BCD number
8101 00
8102 80
8103 47 MOV B, A Save it
8104 E6

AN 0F Mask most signiIicant Iour bits
8105 0F
8106 4F MOV C, A Save unpacked BCD1 in C register
8107 78 MOV A, B Get BCD again
8108 E6 AN F0 Mask least signiIicant Iour bits
8109 F0
810A 0F RRC Convert most signiIicant Iour bits into unpacked
BCD2 810B 0F RRC
810C 0F RRC
810D 0F RRC
810E 47 MOV B, A Save unpacked BCD2 in B register
810F AF RA A Clear Accumulator
8110 16

MV D, 0A Set D as a multiplier oI 10
8111 0A
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 33

8112 82 OC1 ADD D Add 10 until B)0
8113 05 DCR B Decrement BCD2 by one
8114 C2 JNZ OC1 s multiplication complete? I not, go back and
add again 8115 12
8116 81
8117 81 ADD C Add BCD1
8118 32 STA 8050 Store the result
8119 50
811A 80
811B 76 HT Terminate program execution


b). Hex to BCD:
Memory
address
Hex
Code
Label Mnemonics Comments
8100 31 SP, 8FFF nitialize stack pointer
8101 FF
8102 8F
8103 3A DA 8000 Get the binary number in accumulator
8104 00
8105 80
8106 CD CA OC Call subroutine to convert binary to BCD
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 34

8107 0A
8108 81
8109 76 HT Terminate program execution
810A 06 OC MV B, 64 oad divisor decimal 100 in B register
810B 64
810C 0E MV C, 0A oad divisor decimal 10 in C register
810D 0A
810E 16 MV D, 00 nitialize digit 1
810F 00
8110 1E MV E, 00 nitialize digit 2
8111 00
8112 B8 OC1 CMP B Check iI number decimal 100
8113 DA JC OC2 I yes, go to OC2
8114 1B
8115 81
8116 90 SUB B Subtract decimal 100
8117 1C NR E Update quotient
8118 C3 JMP OC1 Go to OC1
8119 12
811A 81
811B B9 OC2 CMP C Check iI number decimal 10
811C DA JC OC3 I yes, go to OC3
811D 21
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 33

811E 81
811F 91 SUB C Subtract decimal 10
8120 14 NR D Update quotient
8121 C3 JMP OC2 Continue division by 10
8122 1B
8123 81
8124 32 OC3 STA 8200 Store digit 0
8125 00
8126 82
8127 7A MOV A, D Get digit 1
8128 32 STA 8201 Store digit 1
8129 01
812A 82
812B 7B MOV A, E Get digit 2
812C 32 STA 8202 Store digit 2
812D 02
812E 82
812F C9 RET Terminate program execution




Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 36

Output:
a) BCD to Hex:
Input Output
Memory Address Data Memory Address Data
8000 67 8050 43

b)Hex to BCD:
Input Output
Memory Address Data Memory Address Data
8000


8A


8200 08
8201 03
8202 01


Result:
Thus, the assembly language program to convert Irom BCD to Hex and Irom Hex to
BCD is done using 8085 microprocessor.

Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 37

Ex. No.: 1
Date : 06.09.2011
ARITHMETIC OPERATIONS
Aim:
To perIorm the addition, subtraction,multiplication and division oI 8 bit/16 bit numbers using
8086 microprocessor.
Algorithm:
1. oad the values in any oI the register
2. The various arithmetic operations are perIormed using the corresponding commands.
3. The results oI the operations are stored in memory locations.
4. Display the outputs and end the program.
Program:
MOV A, |1000|
MOV B, |1002|
MOV C, A
ADD A, B
MOV |2000|, A
MOV A, C
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 38

SUB A, B
MOV |2002|, A
MOV A, C
MU B
MOV |2004|, D
MOV |2006|, A
MOV A, C
DV B
MOV |2008|, A
NT 3
Execution table:
Memory
Address
Label Mnemonics Comments
3000 MOV A, |1000| oad A register with a 16 bit value
3003 MOV B, |1002| oad B register with a 16 bit value
3006 MOV C, A Copies the contents oI A to C register
3007 ADD A, B Adds the contents oI A and B and stores the result
in A register
3008 MOV |2000|, A Moves the contents oI A to the memory address
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 39

300B MOV A, C Copies the contents oI C to A register
300C SUB A, B Subtracts the contents oI A Irom B and stores the
result in A
300D MOV |2002|, A Moves the contents oI A to the memory address
3010 MOV A, C Copies the contents oI C to A register
3011 MU B Multiplies the contents oI B with A and stores the
32 bit result in D:A
3014 MOV |2004|, D Moves the contents oI D to the memory address
3017 MOV |2006|, A Moves the contents oI A to the memory address
3019 MOV A, C Copies the contents oI C to A register
301A DV B Divides the contents oI A with the 8 bit value in B
register and the result is stored in AH and A register
301D MOV |2008|, A Moves the contents oI A to the memory address
3020 NT 3 Enters wait state






Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 60

Output table:
Input Output
Memory address Data Memory address Data
1000 46 2000 56
1001 14 2001 1B
1002 10 2002 36
1003 07 2003 0D
1004 2004 8F
1005 2005 00
1006 2006 60
1007 2007 2E
1008 2008 14
1009 2009 46



Result:
Thus the various arithmetic operations are perIormed using 8086 microprocessor and their
outputs are veriIied.

Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 61

Ex. No.: 2
Date : 13.09.2011
SORTING AN ARRAY IN ASCENDING ORDER
Aim:
To sort an array oI elements in ascending order using 8086 microprocessor.
Algorithm:
1. Compare the Iirst two 8-bit numbers in the memory.
2. nterchange them iI the value in Iirst memory location is greater than the value in second
memory location. Otherwise, don`t interchange.
3. Compare the contents oI second and third memory location and, interchange iI needed.
4. Continue this process till the last two numbers are compared and interchanged.
5. Repeat the above steps n-1 times.





Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 62

Program:
MOV C, |2000|
OC 3: MOV CH, C
MOV S, |2002|
OC 2: MOV A, |S|
NC S
CMP A, |S|
JBE OC 1
MOV B, |S|
MOV |S|, A
DEC S
MOV |S|, B
NC S
OC 1: DEC CH
JNZ OC 2
DEC C
JNZ OC 3
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 63

NT 3
Execution table:
Memory
Address
Label Mnemonics Comments
1000 MOV C, |2000| Moves the content oI memory address to C register
1004 OC 3 MOV CH, C Copies the contents oI C to CH register
1006 MOV S, 2002 Assigns the immediate value to S register
1009 OC 2 MOV A,|S| Moves the content oI memory address stored in S
register to A
100B NC S ncrements the value oI S
100C CMP A, |S| Compares the content oI memory address stored in S
register with the contents oI A
100E JBE OC 1 I the value in A is less than or equal to the value
compared, the control is transIerred to OC 1
1010 MOV B, |S| Copies the content oI memory address stored in S to B
register
1012 MOV |S|, A Copies the content oI A to the memory address stored
in S register
1014 DEC S Decrements the value oI S by 1
1015 MOV |S|, B Copies the contents oI B to the memory address stored
in S register
1017 NC S ncrements the value oI S by 1
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 64

1018 OC 1 DEC CH Decrements the value oI CH register by 1
101A JNZ OC 2 I the above operation results in zero then the control is
transIerred to OC 2
101C DEC C Decrement the value oI C by1
101E JNZ OC 3 I the above operation results in zero then the control is
transIerred to OC 3
1020 NT 3 Enters wait state

Output:
Input Output
Memory address Data Memory address Data
2000 05 2002 01
2001 00 2003 04
2002 05 2004 05
2003 04 2005 09
2004 32 2006 32
2005 09
2006 01

Result:
Thus, sorting an array oI 8-bit numbers in ascending order is perIormed using 8086
microprocessor.
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 63

Ex no.: 3
Date : 13.09.2011
SORTING AN ARRAY IN DESCENDING ORDER
Aim:
To sort an array oI elements in descending order using 8086 microprocessor.
Algorithm:
1. Compare the Iirst two 8-bit numbers in the memory.
2. nterchange them iI the value in Iirst memory location is lesser than the value in second
memory location. Otherwise, don`t interchange.
3. Compare the contents oI second and third memory location and, interchange iI needed.
4. Continue this process till the last two numbers are compared and interchanged.
5. Repeat the above steps n-1 times.





Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 66

Program:
MOV C, |2000|
OC 3: MOV CH, C
MOV S, |2002|
OC 2: MOV A, |S|
NC S
CMP A, |S|
JAE OC 1
MOV B, |S|
MOV |S|, A
DEC S
MOV |S|, B
NC S
OC 1: DEC CH
JNZ OC 2
DEC C
JNZ OC 3
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 67

NT 3
Execution table:
Memory
Address
Label Mnemonics Comments
1000 MOV C, |2000| Moves the content oI memory address to C register
1004 OC 3 MOV CH, C Copies the contents oI C to CH register
1006 MOV S, 2002 Assigns the immediate value to S register
1009 OC 2 MOV A,|S| Moves the content oI memory address stored in S
register to A
100B NC S ncrements the value oI S
100C CMP A, |S| Compares the content oI memory address stored in S
register with the contents oI A
100E JAE OC 1 I the value in A is greater than or equal to the value
compared, the control is transIerred to OC 1
1010 MOV B, |S| Copies the content oI memory address stored in S to B
register
1012 MOV |S|, A Copies the content oI A to the memory address stored
in S register
1014 DEC S Decrements the value oI S by 1
1015 MOV |S|, B Copies the contents oI B to the memory address stored
in S register
1017 NC S ncrements the value oI S by 1
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 68

1018 OC 1 DEC CH Decrements the value oI CH register by 1
101A JNZ OC 2 I the above operation results in zero then the control is
transIerred to OC 2
101C DEC C Decrement the value oI C by1
101E JNZ OC 3 I the above operation results in zero then the control is
transIerred to OC 3
1020 NT 3 Enters wait state

Output:
Input Output
Memory address Data Memory address Data
2000 05 2002 32
2001 00 2003 09
2002 05 2004 05
2003 04 2005 04
2004 32 2006 01
2005 09
2006 01

Result:
Thus, sorting an array oI 8-bit numbers in descending order is perIormed using 8086
microprocessor.
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 69

Ex. No.: 4
Date : 20.09.2011
FACTORIAL OF A NUMBER
Aim:
To Iind the Iactorial oI a given number using 8086 microprocessor.
Algorithm:
1. Get the number Irom the memory.
2. Check whether the number is greater than 1 or not. I no, store the result as 1.
Otherwise, go to step 3.
3. Compute n * n-1) until the value oI n-1 becomes zero.
4. Store the result in the memory.
Program:
MOV C, |2000|
MOV A, C
CMP C, 0001
JBE OC 3
DEC C
MU C
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 70

DEC C
JNZ OC 2
MOV |2002|, A
JMP OC 1
MOV B, 0001
MOV |2002|, B
NT 3
Execution Table:
Memory
Address
Label Mnemonics Comments
1000 MOV C, |2000| Move the contents oI the memory location to C register
1003 MOV A, C Copy the contents oI C to A register
1004 CMP C, 0001 Compare the immediate value with C register
1007 JBE OC 3 I the compared value is less than or equal to C then the
control is transIerred to OC 3
100A DEC C Decrements the value oI C by 1
100B MU C Multiplies C with A
100C DEC C Decrements the value oI C by 1
100F JNZ OC 2 I the above operation does not result in zero, then the
control is transIerred to OC 2
Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 71

1012 MOV |2002|,A Moves the content oI A to the memory location
1015 JMP OC 5 TransIers control to OC 5
1018 MOV B, 0001 Moves immediate value to B
101B MOV |2002|,B Stores the value in B to memory location
101E NT 3 Enters wait state

Output:
Input Output
Memory address Data Memory address Data
2000 05 2002 78
2001 00 2003 00





Result:
Thus the Iactorial oI a number is Iound using 8086 microprocessor and the output is veriIied.


Niciopiocessoi anu Niciocontiollei Lab Nanual

age | 72