ASM program to arrange an array of data in ascending order using 8085

AIM: To write a program to arrange an array of data in ascending order

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

PROGRAM:

        LXI H,4200
        MOV C,M
        DCR C 
REPEAT: MOV D,C
        LXI H,4201
LOOP:   MOV A,M
        INX H
        CMP M
        JC SKIP
        MOV B,M
        MOV M,A
        DCX H
        MOV M,B
        INX H
SKIP:   DCR D
        JNZ LOOP
        DCR C
        JNZ REPEAT
        HLT

OBSERVATION:


Input:

4200

05 (Array Size)

420105

420204

420303

420402

420501

Output:

4200

05(Array Size)

420101

420202

420303

420404

420505

RESULT: Thus the given array of data was arranged in ascending order.

Editorial Team
Editorial Team

We are a group of young techies trying to provide the best study material for all Electronic and Computer science students. We are publishing Microcontroller projects, Basic Electronics, Digital Electronics, Computer projects and also c/c++, java programs.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in