Logo 
Search:

Assembly Language Articles

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

Program to compare two strings. Use subroutine

Posted By: Ramond Fischer     Category: Assembly Language     Views: 12009

Write a program to compare two strings. Use subroutine.

Code for Program to compare two strings. Use subroutine in Assembly Language

DIS MACRO STR
        MOV AH,09H
        LEA DX,STR
        INT 21H
ENDM
DATA SEGMENT
MSG1 DB "ENTER THE STRING : $"
MSG2 DB "STRING ARE EQUAL$"
MSG3 DB "STRING ARE NOT EQUAL$"
LINE DW 10,13,'$'
STR1 DW 20 DUP('$')
STR2 DW 20 DUP('$')
DATA ENDS
CODE SEGMENT
         COMPARE PROC NEAR
         ASSUME CS:CODE
         MOV CX,0000
         MOV CL,BYTE PTR[SI]
         INC SI
         MOV BL,00
      L1:MOV AH,BYTE PTR[SI]
         CMP BYTE PTR[DI],AH
         JNE L2
         INC BL
      L2:INC SI
         INC DI
         LOOP L1
         RET
         COMPARE ENDP
         ASSUME DS:DATA,CS:CODE
START:
         MOV AX,DATA
         MOV DS,AX
         DIS MSG1
         MOV AH,0AH
         LEA DX,STR1
         INT 21H
         DIS LINE

         DIS MSG1
         MOV AH,0AH
         LEA DX,STR2
         INT 21H

         LEA SI,STR1+1
         LEA DI,STR2+2
         CALL COMPARE

         DIS LINE
         LEA SI,STR1+1
         CMP BL,BYTE PTR[SI]
         JNE L4
         DIS MSG2
         JMP L5
      L4:DIS MSG3
      L5:MOV AH,4CH
         INT 21H
CODE ENDS
END START

;------
;OUTPUT
;------

    ENTER THE STRING : JINESH
    ENTER THE STRING : JINESH
    STRING ARE EQUAL

    ENTER THE STRING : JINESH
    ENTER THE STRING : SHAH
    STRING ARE NOT EQUAL
  
Share: 


Didn't find what you were looking for? Find more on Program to compare two strings. Use subroutine Or get search suggestion and latest updates.

Ramond Fischer
Ramond Fischer author of Program to compare two strings. Use subroutine 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!