cmp byte ptr[ecx],"a"
jnz @f
pop ebx
;push eax
push ecx
push edx
GetArrayValue list,edx
mov ecx,eax
@loop:
lea edx,buf[ebx]
cmp byte ptr[edx],"b"
jnz @f
inc eax
@@:
loop @loop
;SetArrayValue list,edx,eax

pop edx
pop ecx
;pop eax
jmp @loopStart
@@:


This code does not work but this one do:


cmp byte ptr[ecx],"a"
jnz @f
pop ebx
;push eax
push ecx
push edx
GetArrayValue list,edx
mov ecx,eax
@loop:
lea edx,buf[ebx]
cmp byte ptr[edx],"b"
jnz @next
inc eax
@next:
loop @loop
;SetArrayValue list,edx,eax

pop edx
pop ecx
;pop eax
jmp @loopStart
@@:


Both codes complies but when i run the first code XP tell me that my program made and error and close.
Why? i dont understand. :(
Posted on 2004-06-24 19:50:41 by bj1500
hum, i just understood why the first code dont work. i got two @@: and if the first cmp fail it just jump right into my code :/
thats why it not works.
i really should start to think about my problems abit more. sorry for posting this question :(
Posted on 2004-06-24 19:59:57 by bj1500
the unnamed labels always go to the *nearest* @@: label - they don't care about source code indentation.

You could use a masm-style "if" to handle your outer if block, the one with the cmp byte ptr,"a", the generated code should be just fine.

Also, don't use "loop", it's a slow instruction.
Posted on 2004-06-24 20:01:55 by f0dder
Okey, what should i use?
just create a simple label and jump to it every time and decrement ecx?
or is it any "faster" way to loop?
Posted on 2004-06-24 20:05:25 by bj1500
The "loop xxx" instruction essentially replaces the following set of instructions.

dec ecx
jnz xxx

Although the "loop" instruction may be slower than the above pair of instructions, it may cost you less than a few microseconds which you will not even notice if you loop less than a few thousand times. You should avoid the "loop" instruction primarily when you are doing animation or processing huge amounts of data.

Raymond
Posted on 2004-06-24 22:49:09 by Raymond
loop has only +/- 127 byte range
jnz has a longer opcode version
Posted on 2004-06-24 22:54:34 by comrade