write a program in assembly languge o find if two given strings are of equal lenght
Answers
Answered by
0
DATA SEGMENT
STR1 DB ‘GANGADHAR$’
STR2 DB ‘KOPELLA$’
MSG1 DB 10,13,’LENGTH OF THE STRING 1 IS :- $’
MSG2 DB 10,13,’LENGTH OF THE STRING 2 IS :- $’
MSG3 DB 10,13,’STRING ARE OF EQUAL LENGTH$’
MSG4 DB 10,13,’STRING ARE OF NOT EQUAL LENGTH$’
LEN1 DB 0H
LEN2 DB 0H
DATA ENDS
DISPLAY MACRO MSG
MOV AH,9
LEA DX,MSG
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA SI,STR1
NEXT1:
CMP [SI],’$’
JE DONE1
INC LEN1
INC SI
JMP NEXT1
DONE1:
DISPLAY MSG1
MOV AL,LEN1
ADD AL,30H
MOV DL,AL
MOV AH,2
INT 21H
LEA DI,STR2
NEXT2:
CMP [DI],’$’
JE DONE2
INC LEN2
INC DI
JMP NEXT2
DONE2:
DISPLAY MSG2
MOV AL,LEN2
ADD AL,30H
MOV DL,AL
MOV AH,2
INT 21H
MOV AL,LEN1
CMP AL,LEN2
JE EQUAL
DISPLAY MSG4
JMP EXIT
EQUAL:
DISPLAY MSG3
EXIT:
MOV AH,4CH
INT 21H
CODE ENDS
END START
Similar questions