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
Posted on 2001-02-17 06:42:00 by 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
Posted on 2001-02-17 08:56:00 by hutch--
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
Posted on 2001-02-17 16:00:00 by 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
Posted on 2001-02-17 22:08:00 by vReal
have a look at the string tutorial on my :D site. i explained there how to use several string commands and operations.
Posted on 2001-02-18 07:25:00 by [SaFc0n]
thx. a lot. I will read the two tuts on this. :) I think this will help me to solve my problem :D sign CyBerian
Posted on 2001-02-19 06:12:00 by 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
	inc    esi             ; increment index
	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 AM
Posted on 2001-02-19 08:33:00 by Q
thx. 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 :)
Posted on 2001-02-20 16:26:00 by CyBerian