02-Write an ALP in 8086 to perform String manipulation using FAR Procedure

Write an ALP in 8086 to perform String manipulation using FAR Procedure :-
 
                  1) Concatenation of two strings
                2) No. of occurences of sub strings
                     in the given string.


.model small
    disp macro a
   mov ah,09h
   lea dx,a
   int 21h
endm


public str1,str2
EXTRN concatenate:far
EXTRN substring:far

.data

msg1 db 10,13,10,13,"1.Accept 1st string."
     db 10,13,"2.Accept 2nd string."
     db 10,13,"3.Concatenation."
     db 10,13,"4.Substring."
     db 10,13,"5.Exit."
     db 10,13,10,13,"Enter your choice:$"
msg2 db 10,13,10,13,"Invald choice.Re-enter choice.$"
msg3 db 10,13,10,13,"Enter string 1:$"
msg4 db 10,13,10,13,"Enter string 2:$"
msg5 db 10,13,10,13,"The 1st string is:$"
msg6 db 10,13,10,13,"The 2nd string is:$"
msg7 db 10,13,10,13,"The concatenated string is:$"
;msg8 db 10,13,10,13,"The substring is:$"
str1 db 20,?,20 dup("$")
str2 db 20,?,20 dup("$")

.code
   main:
      mov ax,@data
      mov ds,ax

      menu:
         disp msg1
         mov ah,01h
         int 21h
         cmp al,'1'
         je accept1
         cmp al,'2'
         je accept2
         cmp al,'3'
         je concat1
         cmp al,'4'
         je substr1
         cmp al,'5'
         je exit
         disp msg2
         jmp menu

      exit:
         mov ah,4ch
         int 21h

      accept1:
         disp msg3
         mov ah,0AH
         lea dx,str1
         int 21h
         disp msg5
         disp str1[2]
       
         jmp menu

      accept2:
         disp msg4
         mov ah,0AH
         lea dx,str2
         int 21h
         disp msg6
         disp str2[2]
       
         jmp menu

      concat1:
 
         disp msg7
         call concatenate
         disp str1[2]
         jmp menu

      substr1:
         call substring
         jmp menu
   

   end main
end

Previous
Next Post »

Disqus Shortname

Comments system