Write an assembly language program to sort a series of data in ascending order.



Experiment Name: Write an assembly language program to sort a series of data in ascending order.

Objective:
(i) To know about several command in the Assembly language.
(ii) Input a Character.
(iii) Output a Character.

Source Code:
data segment
          arr1 db 8,2,7,4,3
data ends

code segment
assume cs:code, ds:data

begin:
                   mov ax, data
                   mov ds, ax
                   mov es, ax
                   mov bx, offset arr1
                   mov cx, 5
                   mov dx, cx
          l1:
                   mov si, 0
                   mov ax, si
                   inc ax
                   mov di, ax
                   mov dx, cx
          l2:
                   mov al, [bx][si]
                   cmp al, [bx][di]
                   jg l4
          l3:
                   incsi
                   inc di
                   dec dx
                   cmp dx, 00
                   je l1
                   jg l2
          l4:
                   mov al, [bx][si]
                   mov ah, [bx][di]
                   mov [bx][si], ah
                   mov [bx][di], al
                   incsi
                   inc di
                   dec dx
                   cmp dx, 00
                   je l1
                   jg l2
          exit:
                   mov ax, 4c00h
                   int 21h
code ends
end begin

Input/output:

          2, 3, 4, 7, 8

No comments

Dear Members, Thanks for Your Comments. We must be reply your comment answer as soon as possible. Please Stay with us.....

Theme images by ideabug. Powered by Blogger.