Logo 
Search:

Assembly Language Articles

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

PROGRAM TO COMPARE TWO STRINGS WITH AND WITHOUT USING "CMPSB" INSTRUCTION USING MACRO

Posted By: Harrison Evans     Category: Assembly Language     Views: 7870

PROGRAM TO COMPARE TWO STRINGS WITH AND WITHOUT USING "CMPSB" INSTRUCTION USING MACRO.

Code for PROGRAM TO COMPARE TWO STRINGS WITH AND WITHOUT USING "CMPSB" INSTRUCTION USING MACRO in Assembly Language

GETSTR MACRO STR
MOV AH,0AH
LEA DX,STR
INT 21H
ENDM

PRINTSTR MACRO STR
MOV AH,09H
LEA DX,STR
INT 21H
ENDM

DATA SEGMENT

        STR1 DB 80,80 DUP('$')
        STR2 DB 80,80 DUP('$')
        MSG1 DB 10,13,'ENTER THE FIRST STRING :$'
        MSG2 DB 10,13,'ENTER THE SECOND STRING IS :$'
        MSG3 DB 10,13,'THE TWO STRINGS ARE EQUAL$'
        MSG4 DB 10,13,'THE TWO STRINGS ARE NOT EQUAL$'
DATA ENDS


CODE SEGMENT

        ASSUME CS:CODE,DS:DATA,ES:DATA
        START:

                 MOV AX,DATA
                 MOV ES,AX
                 MOV DS,AX
        
                 PRINTSTR MSG1
                 GETSTR STR1
                 PRINTSTR MSG2
                 GETSTR STR2
               
                 LEA SI,STR1+2
                 LEA DI,STR2+2
               
                 MOV CL,STR1+1 ;FOR STORING THE LENGTH OF THE STRING
                 MOV CH,00H
        
                 REPE CMPSB
                 JNE NOTEQUAL
        
                 PRINTSTR MSG3
                 JMP JAY1
        
             NOTEQUAL:
                 PRINTSTR MSG4
        
             JAY1:      
                 MOV AX,4C00H
                 INT 21H
        
CODE ENDS
        END START

OUTPUT
***********

D:\tasm\tasm1>m12

ENTER THE FIRST STRING :ABC
ENTER THE SECOND STRING IS :XYZ
THE TWO STRINGS ARE NOT EQUAL
D:\tasm\tasm1>m12

ENTER THE FIRST STRING :XYZ
ENTER THE SECOND STRING IS :XYZ
THE TWO STRINGS ARE EQUAL
  
Share: 



Harrison Evans
Harrison Evans author of PROGRAM TO COMPARE TWO STRINGS WITH AND WITHOUT USING "CMPSB" INSTRUCTION USING MACRO is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 

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!