News:

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

Split A String

Started by 2-Bit Chip, August 20, 2009, 12:23:46 AM

Previous topic - Next topic

2-Bit Chip

Would there be any macros for this?

dedndave

there are quite a few macros for strings in the masm32 package
see the help file named "masm32\help\hlhelp.chm" - look under "macro catagories" - "string macros"

2-Bit Chip

Quote from: dedndave on August 20, 2009, 12:49:04 AM
there are quite a few macros for strings in the masm32 package
see the help file named "masm32\help\hlhelp.chm" - look under "macro catagories" - "string macros"

None for splitting a string. ::)

dedndave

well - i think left$ and right$ might be useful
i sometimes use them with uhex$ because uhex$ only accepts a dword register and i may want a byte or word

print right$(uhex$(eax),4)

that essentially takes the right-hand 4 characters of the uhex$ string and makes a new string out of it
i could use them together

print left$(right$(uhex$(eax),4),2)

that would show me the hex value of AH

someString db 'hello world',0

right$(left$(ADDR someString,5),1)
that would return the address of a new string in eax = "o",0

hutch--

2 bit,

Depends of what you want to split and by what criterion. Tell us what you are trying to do and we may be able to help you.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

2-Bit Chip

Split a string in half.

hello, there

I will not know how long the first section (before comma) will be.

hutch--

Its probably a very simple algo you need, read everything up to the ",", place it in one buffer, read everything up to the end of the string AFTER the "," into a second buffer. If you can modify the original, overwrite the first "," with a zero. Use the original address for the first then use the address of the character following the "," as the second address.

That is probably the fastest way to do it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

2-Bit Chip

Alright, thank you hutch.