Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .MODEL SMALL
- .STACK
- .DATA
- M1 DB 13,10,'ENTER THE FIRST STRING:$'
- M2 DB 13,10,'ENTER THE SECOND STRING:$'
- M3 DB 13,10,'LENGTH OF THE FIRST STRING:$'
- M4 DB 13,10,'LENGTH OF THE SECOND STRING:$'
- M5 DB 13,10,'THE TWO STRING ARE EQUAL:$'
- M6 DB 13,10,'THE TWO STRING ARE NOT EQUAL:$'
- STR1 DB 80 DUP(20)
- STR2 DB 80 DUP(20)
- LEN1 DB ?
- LEN2 DB ?
- DISP MACRO MSG
- LEA DX,MSG
- MOV AH,09H
- INT 21H
- ENDM
- .CODE
- ;Linking up the Datasegment
- MOV AX,@DATA
- MOV DS,AX
- MOV ES,AX
- ;Getting first string from user
- DISP M1
- LEA DX,STR1
- CALL READS
- ;Getting second string from user
- DISP M2
- LEA DX,STR2
- CALL READS
- ;Getting length of the first string
- MOV AL,[STR1+1]
- MOV LEN1,AL
- ;Getting length of the second string
- MOV AL,[STR2+1]
- MOV LEN2,AL
- ;Comparing the length of both the strings and jumping to STRNOTE if they're not equal
- CMP AL,LEN1
- JNE STRNOTE
- ;Comparing each characters of string incase both the lengths are equal
- MOV CH,0
- MOV CL,LEN1
- LEA SI,STR1+2
- LEA DI,STR2+2
- CLD
- REPE CMPSB
- JNE STRNOTE
- ;Displaying that both strings are qual
- DISP M5
- JMP NEXT
- ;Displaying that both strings are not equal
- STRNOTE:
- DISP M6
- NEXT:
- ;Displaying the length of first string
- DISP M3
- MOV AL,LEN1
- CALL DISPLAY
- ;Displaying the length of second string
- DISP M4
- MOV AL,LEN2
- CALL DISPLAY
- ;Quitting the program
- MOV AH,4CH
- INT 21H
- ;Procedure to read an entire string
- READS PROC
- MOV AH,0AH
- INT 21H
- RET
- READS ENDP
- ;Procedure to dispaly a number in string format using AAM
- DISPLAY PROC
- ;ASCII Adjustment After Multiplication
- AAM
- MOV BX,AX
- ;Adding 3030 to conver the data to its ASCII form to display on screen
- ADD BX,3030H
- ;Displaying MSB
- MOV DL,BH
- MOV AH,02H
- INT 21H
- ;Displaying LSB
- MOV DL,BL
- INT 21H
- RET
- DISPLAY ENDP
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement