MASM32 program to tell if strings are different or the same

Viewed 87

I've trying to make a code in MASM32 to tell if two strings inserted by the user are different from another and when I run it it tells that both are different, even when they aren't.

Here's my code:

.386
.model flat, stdcall
option casemap :none


include \masm32\include\masm32rt.inc

.data
    prompt db "Insert string:",0
    same_msg db "Both string are the same.",0
    diff_msg db "The strings are different.",0
    string db 50 dup(?)
    string2 db 50 dup(?)

.code

main:
    push offset prompt
    call StdOut

    push 50
    push offset string
    call StdIn

    push offset prompt
    call StdOut

    push 50
    push offset string2
    call StdIn

    call crt__stricmp
    cmp eax, 0
    je same
    jne diff

same:
    push offset same_msg
    call StdOut

diff:
    push offset diff_msg
    call StdOut

end main

Output:

Insert string:123 Insert string:123 The strings are different.

0 Answers
Related