Hi all
As you know I am new to ASM and am not able to figure out how to find the next CR and/or LF in a String.
What I want to do is to scan a string starting at a defined position for the next CR or LF. Then I need to get the position of this CR or LF
I hope one of you can help me
Another thing I don't get is to retrieve one single character out of a string. e.g. I want to get the 17th character out of a string how to do this?
sign CyBerian
CyBerian,
you basically need to scan through the string and act on the 13 and
the 10 to read what you need.
Scanning through the string is no big deal,you must have the address
of the string data and you must set up the loop so it has an exit
condition, either by a known length or an ascii zero terminator.
You would make a temporary write to buffer that receives each
string until the next CRLF and when u have reached it in the byte
scan, you write the temporary buffer to wherever you need.
Getting the 17th character is a lot easier to do, treat the string as
a BYTE array and use something like => mov al, MyString[16] to move
a single byte into AL.
Regards,
hutch@pbq.com.au
I didn't know that it is possible to get a character of a string like I got a character of an array.
This helps me a lot :D
But I am not quite sure how to do this bytescan thing. I have tried some different things, but non of them worked. Probably you might give me an example of how to do something like this.
sign CyBerian
Hi.
For a good example, go to Iczelion's Win32 Assembly Tutorials page
and study _masta_'s Win32Asm Tut 1. It shows exactly how to do a
scan for certain bytes. Even though it's written in Tasm, the code
is straight forward and can easily be ported to Masm if necessary.
Good luck.
vReal
have a look at the string tutorial on my :D site. i explained there how to use several string commands and operations.
thx. a lot. I will read the two tuts on this. :)
I think this will help me to solve my problem :D
sign CyBerian
Here's one way to scan for CR/LF:
lea esi,MyString ; Index to scan start address
xor ecx,ecx ; zero counter
jmp scanString
keepLooking:
inc esi ; increment index
scanString:
inc ecx ; increment counter
cmp byte ptr ,0Dh ; is it a CR?
jz foundIt
cmp byte ptr ,0Ah ; is it a LF?
jnz keepLooking
foundIt: ; All done.
At the end of this, ECX will contain index to where the CR or LF was found, i.e. ECX=1 means first character...
If you don't need a counter, delete any lines that reference ECX. A counter is a good idea, though... especially so you can set "max-iterations", i.e. zero-out counter and exit loop if string goes beyond specified length, then check if counter=0, string longer than specified.
Is easily modifiable if you need a different start-point, etc.
This message was edited by Q, on 2/19/2001 8:37:04 AMthx. a lot. this is exactly what I needed.
I start to love this board.
And, learning more and more about Asm, I start loving it too :)