Hello

i want to compare a char in a string
LOCAL buf[2048]:DWORD


xor ecx,ecx
@StartLoop:
inc ecx
mov edx,[buf + ecx]
cmp edx,'.'
jnz @StartLoop
mov eax,ecx


the string begins like this: 345. or 23. or 1. or something like that. alwasy a dot after these numbers.

and then, when i know where this dot is, how do i delete all the numbers (and the dot) ?

:confused:
Posted on 2003-11-29 10:20:41 by bj1500


xor ecx, ecx
lea edx, buf
_loop:
mov al, [edx+ecx]
cmp al, '.'
jz _found
inc ecx
cmp ecx, 2048
jnz _loop
_notfound:
..
_fount:
;value in ecx
...
Posted on 2003-11-29 10:34:28 by roticv
your code is checking for dwords, so it'll never work as you wanted.



lea ecx,buf[-1]
@StartLoop:
inc ecx
cmp byte ptr[ecx],0
jz @F
cmp byte ptr[ecx],"."
jnz @StartLoop
inc ecx
@@:
mov eax,ecx

here eax will contain a pointer to the data that is immediately after the dot.
or if you want to have the start of buf contain the necessary data, then:


lea ecx,buf[-1]
@StartLoop:
inc ecx
cmp byte ptr[ecx],0
jz @F
cmp byte ptr[ecx],"."
jnz @StartLoop
inc ecx
@@:
lea edx,buf
sub edx,ecx
@@:
mov al,[ecx]
mov [ecx+edx],al
inc ecx
or al,al
jnz @B
Posted on 2003-11-29 10:39:27 by Ultrano
greate...



lea eax, [eax + buf - 8]
mov BYTE PTR [eax], 0
lea ecx,buf[-1]
@StartLoop:
inc ecx
cmp byte ptr[ecx],0
jz @F
cmp byte ptr[ecx],"."
jnz @StartLoop
inc ecx
@@:
mov eax,ecx

did it :tongue:

thank you
Posted on 2003-11-29 11:14:30 by bj1500
one more question, what exactly does ptr do?
Posted on 2003-11-29 11:19:19 by bj1500
As you know cmp ,0 compares the memory pointed to by ecx to zero. Unfortunatly the assembler doesn't know what size of memory it should be dealing with. ie are yuo talking about comparing the byte at to 00h, or maybe the dword to 00000000h.

I think Masm assumes dword size by default, to change this you must specify the size of one of the operands with byte ptr or word ptr say.

As for what does ptr do specificially, well its seems to be mostly redundant to be honest. In Fasm for example you woruld simply write cmp byte ,0.

Of course if you don't like typing you can use equates to mimic this in Masm.
Posted on 2003-11-29 11:54:38 by Eóin
Okey, thank you...
Posted on 2003-11-29 12:01:55 by bj1500