Logo 
Search:

Assembly Language Articles

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

Program to search whether a given number is present in a sorted array, if it is not present then insert it at appropriate place

Posted By: Abby Fischer     Category: Assembly Language     Views: 7194

Write an assembly program to search whether a given number is present in a sorted array, if it is not present then insert it at appropriate place.

Code for Program to search whether a given number is present in a sorted array, if it is not present then insert it at appropriate place in Assembly Language

.model small

.data
        num db 14
        arr db 3,5,8,12

.code
        mov ax,@data
        mov ds,ax

        mov cx,4
        mov BX,0000
        L1:
                mov dh,arr[BX]
                cmp dh,num
                jl incBX
                jmp Ins1


                incBX:
                        add BX,1
                        Loop L1

        Ins1:
                mov DX,BX
                mov BX,3
                Shft:
                        mov ch,arr[BX]
                        mov arr[BX+1],ch
                        sub BX,1
                        cmp DX,BX
                        jle Shft

                        
                mov ah,num
                mov BX,DX
                mov arr[BX],ah

        mov ax,4C00h
        int 21h

end
  
Share: 



Abby Fischer
Abby Fischer author of Program to search whether a given number is present in a sorted array, if it is not present then insert it at appropriate place is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
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!