The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Sponge Magnet on July 26, 2009, 01:22:40 AM

Title: Strings..
Post by: Sponge Magnet on July 26, 2009, 01:22:40 AM

        mov lpHash, input()
        mov eax, [lpHash]
        mov szHash, eax


There is no way to get the contents of the user input?
Title: Re: Strings..
Post by: dedndave on July 26, 2009, 03:35:45 AM
input() returns an address to the zero-terminated string (or, at least, i am pretty sure it is terminated - lol)

mov eax,input()
mov InputStringPointer,eax
print eax
print chr$(13,10)

you can also use it to display the prompt text

mov eax,input("Enter Value: ")

refer to the help file: \masm32\help\hlhelp.chm
under macros - console mode macros
Title: Re: Strings..
Post by: Sponge Magnet on July 26, 2009, 03:45:21 AM
Quote from: dedndave on July 26, 2009, 03:35:45 AM
input() returns an address to the zero-terminated string (or, at least, i am pretty sure it is terminated - lol)

mov eax,input()
mov InputStringPointer,eax
print eax
print chr$(13,10)

you can also use it to display the prompt text

mov eax,input("Enter Value: ")

refer to the help file: \masm32\help\hlhelp.chm
under macros - console mode macros

It's just that I can not get the length of a string using its pointer (i,e: lpHash)

        mov lpHash, input()
        mov szHash, [lpHash]
        mov szHashSize, SIZEOF szHash


^ Attempting to move the string itself by de-referencing the pointer. Ends in an error.
Title: Re: Strings..
Post by: dedndave on July 26, 2009, 03:50:40 AM
ohhhh - lol
i am not sure how to do that, other than counting bytes
they probably have a macro.....
try this one.....

mov lpHash,input()
mov ecx,len(eax)

same help file - under string macros
they probably use REPNZ SCASB in that macro
Title: Re: Strings..
Post by: Sponge Magnet on July 26, 2009, 03:56:10 AM
Aww! Thank you so much dedndave! Amazing  :cheekygreen:
Title: Re: Strings..
Post by: dedndave on July 26, 2009, 03:57:41 AM
wow - it actually worked - lol