News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

String Help

Started by Trope, March 24, 2005, 12:08:52 AM

Previous topic - Next topic

Trope

Let's say I have a string:

myName db "trope",0


How would I loop through each character and perform some calculation on it? For instance, to make this simple, add 1 to each char's ascii code.

Thanks!

Trope

Phoenix

Hi Trope,

try something like this:


.DATA
szName db "trope",0

.CODE
_StringOp PROC

lea edx, szName
@@:
        mov al, [edx]
test al,al
jz @F
add BYTE PTR [edx],1
inc edx
jmp @B
@@:
        invoke MessageBox,NULL,ADDR szName,ADDR szName,MB_OK

        xor eax,eax
RET

_StringOp EndP


This will display the resulting string "uspqf". Hope it helps.

Regards, phoenix