Hello
i want to compare a char in a string
LOCAL buf[2048]:DWORD
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:
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:
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
...
your code is checking for dwords, so it'll never work as you wanted.
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
@@:
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
greate...
did it :tongue:
thank you
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
one more question, what exactly does ptr do?
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.
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.
Okey, thank you...