.model large
.stack 100h
.DATA
        STR1 DB "ENTER YOUR NAME HERE : $"
       STR2 DB "JABBAR$"
    INSTR1 DB 20 DUP("$")
    INSTR2 DB 20 DUP("$")
    N DB ?
        S DB ?
    NEWLINE DB 10,13,"$"
        MSG1 DB "HAPPY BIRTHDAY BRO MAY BLESSINGS OF ALLAH BE UPON YOU (^_^)$"
        MSG2 DB "SORRY It'S NOT YOUR BIRTHDAY :P $"



.CODE

main proc

        MOV AX,@DATA
        MOV DS,AX

        LEA SI,instr1
        LEA DI,instr2

;GET STRING
        MOV AH,09H
        LEA DX,STR1
        INT 21H

        MOV AH,0AH
        MOV DX,SI
        INT 21H



        LEA DX,str2


    mov dx,di




;STRING COMPARISION


lab1:inc di     ;ds:di -> next character in string2
    lodsb       ;load al with next char from string 1
            ;note: lodsb increments si automatically
    cmp [di], al    ;compare characters
    jne l1      ;jump out of loop if they are not the same
    cmp al, 0   ;they are the same, but end of string?
    jne lab1    ;no - so go round loop again
            ;-----------------------------------------------------------------------------
            ;end of string, and the "jne NotEqual" instruction hasn't been executed so they're equal
            ;-----------------------------------------------------------------------------
    lea dx, msg1    ;point ds:dx at message to say so
    mov ah, 9   ;print message
    int 21h
    jmp l5      ;continue with rest of program

      L1:MOV AH,09H
        LEA DX,MSG2
        INT 21H



     L5:
        MOV AH,1
        INT 21H

        MOV AH,4CH
        INT 21H


main ENDp
END main

Recommended Answers

All 2 Replies

Which specific problems are you having?

I am first getting a string as input and then comparing it with a pre defined string and then printing a message but every time result is false even if both strings are equal. what should i do??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.