Logo 
Search:

Assembly Language Articles

Submit Article
Home » Articles » Assembly Language » Homework HelpRSS Feeds

Program to sort a list in ascending order using binary search

Posted By: Volker Fischer     Category: Assembly Language     Views: 5967

Write an application to sort a list in ascending order using binary search.

Code for Program to sort a list in ascending order using binary search in Assembly Language

.model small

.data
        arr db 2,4,6,8,10
        mid db ?
        num  db 7
        strfound  db  "Found" ,'$'
        strNot    db  "Not Found" ,'$'

.code
        mov ax,@data
        mov ds,ax

        LEA SI,arr
        mov ax,SI
        add ax,4
        mov DI,ax
        mov dl,2

        L1:
                mov ax,SI
                add ax,DI
                div dl
                mov BX,00
                mov Bl,al
                mov bh,00
                mov al,BYTE PTR [BX]
                cmp al,num
                je ans
                jl Less

                sub BX,1
                mov DI,BX
                cmp SI,DI
                jle L1

                jmp Nfound


        Less:
               add BX,1
               mov SI,BX

               cmp SI,DI
               jle L1

               jmp Nfound



        ans:
                mov ah,09h
                LEA DX,strfound
                int 21h
                jmp ext

        Nfound:
                mov ah,09h
                LEA DX,strNot
                int 21h
                jmp ext


        ext:
                mov ax,4C00h
                int 21h                       
end
  
Share: 



Volker Fischer
Volker Fischer author of Program to sort a list in ascending order using binary search is from Frankfurt, Germany.
 
View All Articles

 

Other Interesting Articles in Assembly Language:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!