Microprocessor 8085 program to arrange numbers in Ascending order

TANSCHE third year B.Sc. Physics practical to arrange a set of numbers in ascending order using microprocessor 8085


In the third year of the B.Sc. Physics practical program under TANSCHE, it's crucial to grasp how microprocessors work. A significant part of this involves the Microprocessor 8085, which is a popular 8-bit processor. In this experiment, students get to practice basic arithmetic operations.

This blog post will highlight the experiment to arrange a set of numbers in ascending order using microprocessor 8085. This hands-on activity helps students dive into the essential features of the 8085 microprocessor, including programming logic and memory functions. By completing this task, you'll develop a clear understanding of how the 8085 processes data and performs arithmetic operations, laying a strong groundwork in microprocessor systems.

Microprocessor 8085 program to arrange numbers in Ascending order

Aim:

Write an assembly language program to arrange a set of numbers in ascending order using microprocessor 8085.

Apparatus required:

Microprocessor 8085 kit, power supply etc

Program:

Ascending order - Main program

Memory address

Machine code

Mnemonics

Operands

Comments

8000

11

LXI

D, 8601H

Memory location to store the result

8001

01

8002

86

8003

21

LXI

H, 8500H

Count address in H-L pair

8004

00

8005

85

8006

46

MOV

B, M

Move data in memory to B

8007

CD

CALL

8200H

Call the subroutine in 8200H

8008

00

8009

82

800A

12

STA

D

Store the result

800B

CD

CALL

8050H

Call the subroutine in 8050H

800C

50

800D

80

800E

13

INR

D

Increment D register

800F

05

DCR

B

Decrement B register

8010

C2

JNZ

8007H

Is B non-zero? Jump to 8007H

8011

07

8012

80

8013

76

HLT

Stop the program

Subroutine 1:

Memory address

Machine code

Mnemonics

Operands

Comments

8200

21

LXI

8500H

Count address

8201

00

8202

85

8203

4E

MOV

C, M

Count in C register to check whether all numbers have been compared

8204

3E

MVI

A, FF

Make accumulator the largest number

8205

FF

8206

23

INX

H

Get the next number

8207

BE

CMP

M

Compare memory with accumulator

8208

DA

JC

820CH

Is it the smallest number in the accumulator? Go to 800D

8209

0C

820A

82

820B

7E

MOV

A, M

Get smallest number in the accumulator

820C

0D

DCR

C

Decrement the count register

820D

C2

JNZ

8206H

Is C non-zero? Go to 8206H

820E

06

820F

82

8210

C9

RET

Return to main program

Subroutine 2:

Memory address

Machine code

Mnemonics

Operands

Comments

8050

21

LXI

8500H

Count address

8051

00

8052

85

8053

4E

MOV

C, M

Count in C register to check whether all numbers have been compared

8054

23

INX

H

Get the next number

8055

BE

CMP

M

Compare memory with accumulator

8056

CA

JZ

805D

Is it the larger number in the accumulator? Go to 805D

8057

5D

8058

80

8059

0D

DCR

C

Decrement the count register

805A

C2

JNZ

8054H

Is C non-zero? Go to 8054H

805B

54

805C

80

805D

3E

MVI

A, FF

Store accumulator by FF

805E

FF

805F

77

MOV

M, A

Replace the largest number by FF

8060

C9

RET

Return to main program

Example:

Arranging in ascending order

        Number of data in a array 8500H - 06

First input location 8501H - 23H

Second input location 8502H - 21H

Third input location 8503H - 14H

Fourth input location 8504H - 10H

Fifth input location 8505H - 04H

Sixth input location 8506H - 18H

Result location

8601H - 04H

8602H - 10H

8603H - 14H

8604H - 18H

8605H - 21H

8606H - 23H

Youtube demo:

Result: 

The assembly programmes for microprocessor 8085 to arrange a set of numbers in ascending order were written and executed using the microprocessor 8085 kit.

Click here for Descending order

For further reading:
External site

Post a Comment

0 Comments