0% found this document useful (0 votes)
9 views

String Compare1

The document describes a program that compares two strings entered by the user. It prompts the user to enter the first and second strings, stores the entries in variables, then compares each character to see if they are equal. If a mismatch is found, it displays that the strings are not equal. If no mismatch is found after comparing all characters, it displays that the strings are equal.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

String Compare1

The document describes a program that compares two strings entered by the user. It prompts the user to enter the first and second strings, stores the entries in variables, then compares each character to see if they are equal. If a mismatch is found, it displays that the strings are not equal. If no mismatch is found after comparing all characters, it displays that the strings are equal.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

String Compare

============================================
.MODEL SMALL

DATA_SEG SEGMENT 'DATA'


ST1 DB "Enter First String: ",'$'
ST2 DB 10,"Enter Second Strind: ",'$'
ST3 DB 100 DUP (?)
ST4 DB 100 DUP (?)
ST5 DB 10,"Strings Are Equal",'$'
ST6 DB 10,"Strings Are Not Equal",'$'

DATA_SEG ENDS

CODE_SEG SEGMENT 'CODE'


ASSUME CS:CODE_SEG,DS:DATA_SEG,SS:STACK_SEG

START PROC FAR


MOV AX,DATA_SEG
MOV DS,AX

MOV AH,9
MOV DX,OFFSET ST1
INT 21H

MOV ST3[0],97
MOV DX,OFFSET ST3
MOV AH,0AH
INT 21H
MOV BL,ST3[1]
MOV BH,0
MOV ST3[BX+2],'$'

MOV AH,9
MOV DX,OFFSET ST2
INT 21H

MOV ST4[0],97
MOV DX,OFFSET ST4
MOV AH,0AH
INT 21H
MOV BL,ST4[1]
MOV BH,0
MOV ST4[BX+2],'$'

MOV AL,ST3[1]
MOV AH,ST4[1]
SUB AL,AH
JNE NOT_EQUAL

MOV DI,2
MOV BL,ST4[1]
MOV BH,0
MOV CX,BX

AGAIN: MOV AL,ST3[DI]


MOV AH,ST4[DI]
SUB AL,AH
JNE NOT_EQUAL
ADD DI,1
LOOP AGAIN

JMP EQUAL

NOT_EQUAL: MOV AH,9


MOV DX,OFFSET ST6
INT 21H
JMP END_PROGRAM

EQUAL: MOV AH,9


MOV DX,OFFSET ST5
INT 21H
JMP END_PROGRAM

END_PROGRAM: MOV AH,08


INT 21H
MOV AH,4CH
INT 21H

START ENDP
CODE_SEG ENDS
STACK_SEG SEGMENT STACK
DW 100 DUP(?)
STACK_SEG ENDS

END START

http://www.ravianeducation.blogspot.com
FARHAN: 03008855006

You might also like